Files
automation-based-email-list…/tasks/2026-08-13-initial-system-build-plan.md
T
2026-08-15 15:05:39 -06:00

167 lines
11 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
The repository is still at the planning stage: it currently contains the specification and system map, with no application scaffold. Its main branch also tracks a remote that is currently marked gone, so we should resolve remote/deployment access before the first push. We’ll work through these stages, stopping after each for local testing, review, and your approval.
# Foundation and decisions
Confirm the v1 choices that affect architecture: sender and Postmark stream, telemetry API/auth contract, default follow-up policy, scheduler, consent fields, backup retention, deployment host paths, and durable authorization-record format. Confirm the Git remote.
- We will use Post Mark and credentials will be supplied in an .env file when needed
- telemetry is sent to ops monitor VM - details here: C:\projects\infra\software\ops-monitor
- default follow-up/send on non opens is 4-days
- I backup the server manually as needed for List Monk using these terminal commands. We will want to do something simple as well for this new email system
````login to server and: ~/backup-listmonk.sh
from wsl workstation: scp -i ~/.ssh/example_ssh_key [email protected]:/path/to/private-backups/listmonk-*.tar.gz /path/to/local/backups/
delete server files, but list first: ls -lh ~/backups/listmonk/
delete with y : rm -i ~/backups/listmonk/listmonk-*.tar.gz.
````
- the app will live in this machine: 10.0.0.10. Access latest fleetscan on details for this VM as needed: "C:\path\to\fleet-scan.json"
- All skills built follow this template: C:\projects\productivity\ai-prompt-skill-agent-design-template-OPEN
Sender configuration
PaddleNet from_name, from_email, reply_to, physical mailing address/footer copy, and the Postmark Broadcast Message Stream ID. Also confirm which Postmark stream sends welcome email.
- [email protected] is from and reply_to
- 1494 S Perry Park Rd Sedalia CO 80135
- postmark stream id: broadcast-list
- same stream sends welcom email
Telemetry contract
The exact ops-monitor endpoint(s), authentication approach, and request/response shape for:
campaign activity / apparent non-openers
unsubscribe, bounce, and complaint state
A code location or existing endpoint implementation is ideal.
- see this file for the ops-monitor existing post mark ingestion that we are replicating: C:\projects\productivity\email-campaigns-prod-app\tasks-workflows\2026-06-08-indx-postmark-ops-monitor-ingestion-setup.md
Authorization record
Confirm the durable form for a human directive. I recommend a CLI-recorded authorization containing your name, UTC time, an exact directive/reference, campaign hash, Git commit, and the fixed 4-day follow-up rule.
- approved
Welcome email
Approved welcome-email Markdown/content and the rule for whether imported initial subscribers receive it. My recommendation: import them as active without automatically sending a welcome unless you explicitly opt in.
- when new subscribers added, they only get welcome. existing will not
Initial subscribers and consent
The initial addresses must remain out of Git—including the task-plan file. Please provide them later through a private JSONL inbox plus a source/consent note for each (or one documented shared import source). I recommend removing that list from the committed plan now.
- done
Scheduler and backups
Confirm that host cron is acceptable. For backups, choose a retention period and whether the existing manual workstation-copy routine is the v1 off-VM backup method. A practical starting point is daily local SQLite backups retained for 14 days, with manual workstation retrieval.
- approved for backup and rention policy as directed. Eventually we will automate that sends to internal NAS machine.
Deployment convention
Confirm the server deployment directory and whether deployment is: pull the Git revision on the VM, then build with Docker Compose. We’ll keep secrets only in the VM’s .env, never in Git.
- approved
Please clarify these items:
1. Telemetry scope
May we extend Ops Monitor with an authenticated, versioned read API for:
apparent_non_openers(campaign_id)
- approved
campaign event summaries
If yes, should that work be included in this project’s delivery, or delivered as a small companion change in the Ops Monitor repository?
- approved - ammend this document as needed to reflect this
2. PaddleNet webhook setup
Should we create telemetry.example.com, route it through Caddy to Ops Monitor, and configure the Postmark webhook during deployment?
I recommend enabling Delivery, Bounce, Spam Complaint, Open, Link Click, and Subscription Change events.
- approved
2. Sender display name
What should recipients see as the sender name—“PaddleNet,” “PaddleNet Earth,” or another exact value?
- PaddleNET
4. Welcome email
Please provide or point me to the approved welcome-email Markdown. Without it, I can build the welcome mechanism and test it, but cannot create the final production template.
- Here is the file placeholder for now: C:\projects\paddlenet-closed\paddlenet-app\paddlenet-email-list-system\templates\welcome.md
5. VM deployment path
What exact directory should the application use on 10.0.0.10? I can use /srv/email-list-system if that is your preference.
- approved
# Repository scaffold
- Apply the approved repo-template-OPEN software/automation profile - we do not need to do this yet. This email repo is internal for paddlenet. When I create andf open source copy, we can then apply the repo-template to standardize it.
add the Python project, Docker files, ignore rules, public/private-data protections, documentation skeleton, and test tooling.
# Core contracts and CLI shell
Define versioned schemas and stable JSON CLI results, exit codes, dry-run behavior, configuration loading, health/system checks, and structured receipts.
# SQLite foundation
Build migrations, transaction helpers, subscriber/campaign/send-state tables, status history, backups, restore verification, and test database fixtures.
# Campaign authoring and rendering
Implement Markdown + YAML front-matter validation, HTML/plain-text rendering, templates, preview output, content/template hashing, link/footer checks, and rendering snapshot tests.
- we can use this simpel html template when emails are built from the markdown source of truth: "C:\path\to\email-template.html"
# Subscriber operations
Implement normalized subscriber records, status precedence, private JSONL import, exact-once operation processing, subscribe/unsubscribe CLI commands, and sanitized receipts.
# Authorization and campaign lifecycle
Record a directive bound to exact content, template, audience, Git revision, and follow-up parameters; enforce fail-closed approval checks and immutable recipient snapshots.
# Provider boundary and Postmark integration
Create provider-neutral interfaces, a safe test adapter, then the Postmark adapter for broadcasts, welcome messages, idempotency keys, batch failures, and suppressions.
# Sending and safe recovery
Implement the initial campaign send pipeline: backup, suppression reconciliation, recipient selection, per-recipient state, retries/resume, status, and receipts.
# Telemetry and follow-ups
Define and test the telemetry adapter contract with the existing server; implement due follow-up selection, one-follow-up limit, eligibility rechecks, and exception behavior.
# Scheduler and AI operating skill
Add cron-compatible entry points for imports, welcomes, reconciliation, backups, and due follow-ups; document the restricted AI command workflow and escalation boundary.
# Docker, WSL acceptance, and release
Build and run the container locally in WSL; run the full automated suite plus synthetic/test-mode sends, migration/restore, restart/resume, and privacy checks. Then review, commit, push, deploy to the VM, run health and test-mode validation, and tag the release.
For every implementation stage, the gate is: automated tests pass, a focused local scenario passes, documentation is updated, and we review the diff before proceeding.
We should begin with Step 1, because it resolves the few choices that cannot safely be guessed and prevents rework in the schema and deployment layers.
## Deployment Handoff - 2026-08-13
### Completed and verified
- Email-list system is committed and pushed. Current production checkout revision on `email-campaigns-prod-app` is `8783ce6`.
- Ops Monitor companion telemetry API is committed and pushed as `af1ceab`.
- Email-list repository is cloned at `/srv/email-list-system` on `10.0.0.10`.
- The email-list Docker image builds successfully on the VM.
- Private runtime directory is `/srv/email-list-system/runtime`; its SQLite database is initialized at schema version 3.
- The VM health check and test-provider suppression dry-run passed. No real subscribers or emails have been processed or sent.
- The container runs non-root as UID 1000, matching the VM account and writable private runtime directory.
- Ops Monitor source is staged at `/opt/example-email-telemetry` on `ops-monitor-host`; its on-host telemetry test passed.
- `email-telemetry.service` is active.
- The authenticated Ops Monitor API path from the email VM was verified with HTTP 200. Do not expose or rotate the shared telemetry token unless needed; both services must use the same private value.
### Git deployment workaround and ongoing procedure
The public Git URL is Cloudflare-proxied and does not expose Gitea SSH. The internal Tailscale route intercepts SSH as Tailscale SSH rather than routing the `git` user to Gitea. A Gitea SSH deploy key was created but is not the v1 deployment path.
Use a dedicated, read-only Gitea HTTPS access token for this VM instead:
```bash
cd /srv/email-list-system
git status --short --branch
git pull --ff-only origin main
```
Git prompts for the Gitea username and the read-only token as its password when the credential is not cached. Never put this token in a clone URL, `.env`, shell command, source file, Git history, or receipt. Full procedure: `docs/git-deployment-access.md`.
### Remaining deployment checklist for tomorrow
1. On `ops-monitor-host`, add the Caddy route for `telemetry.example.com` forwarding to `10.0.0.20:8000`; validate and reload Caddy.
2. In Cloudflare, create the matching `telemetry.example.com` DNS record using the existing email telemetry domain pattern.
3. In Postmark, configure a `broadcast-list` webhook at `https://telemetry.example.com/postmark` for Delivery, Bounce, Spam Complaint, Open, Link Click, and Subscription Change.
4. On the email VM, add the private Postmark settings to `/srv/email-list-system/.env`:
```ini
EMAIL_LIST_PROVIDER=postmark
POSTMARK_SERVER_TOKEN=<private server token>
POSTMARK_BROADCAST_STREAM_ID=broadcast-list
POSTMARK_FROM_NAME=PaddleNET
[email protected]
[email protected]
```
5. Resume with read-only Postmark suppression verification and webhook health checks. Do not send a real campaign or import real subscribers yet.
6. Replace `templates/welcome.md` with approved PaddleNET copy before enabling welcome cron.
7. Complete the remaining release checklist in `docs/release-checklist.md`, including initial subscriber import with `--no-welcome`, only after the live integrations and human review gates pass.