Skip to content

feat(plane): send Plane mail through the platform SMTP settings [AC-1127] - #1249

Open
jestyr27 wants to merge 12 commits into
devfrom
feat/plane-outbound-mail
Open

jestyr27 wants to merge 12 commits into
devfrom
feat/plane-outbound-mail

Conversation

@jestyr27

@jestyr27 jestyr27 commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

What this changes

Deploy Plane now sends Plane's outbound mail through the platform SMTP settings when the inventory sets smtp_host (plan 29, unit S6, AC-1127).

  • Settings. Phase 3 merges eight instance settings into the settings the existing configure_instance.py step already converges: ENABLE_SMTP, EMAIL_HOST, EMAIL_PORT, EMAIL_HOST_USER, EMAIL_HOST_PASSWORD, EMAIL_USE_TLS, EMAIL_USE_SSL and EMAIL_FROM. Every value is a string, so a second run patches nothing. EMAIL_USE_TLS follows smtp_starttls | default(true) | bool, and EMAIL_USE_SSL stays 0.
  • Token. plane_smtp_token is read from secret/services/smtp through _shared_reads, only while mail is on, and reaches Plane on the stdin of the existing no_log configuration task, as the OIDC secret does. No new no_log task.
  • Guard. tasks/assert-smtp-settings.yml is the first task of Phases 1, 3 and 4, the three plays that read a mail variable.
  • Mail off. No mail key is sent and nothing is cleared. Turning mail off on a running instance is not part of this unit.
  • Local verify. On a local-dev inventory with mail on, Phase 4 finds the one Plane worker container by its compose service label (exact worker, not beat-worker), runs python manage.py test_email <smtp_from_address> in it, and requires the exact line Email successfully sent, because test_email exits 0 when delivery fails. It then checks the Mailpit catcher for a message to that address with subject Test email created since a time marked just before the send. Outside local-dev nothing is sent; the production test send is unit S9.
  • Local network. compose.local.yml puts the Plane worker on local-dev, so it reaches mailpit:1025.

Facts read before the change

Not verified in the current session: read by this unit's earlier owner session on local-dev from the Plane v3.3.3 image and database, names only, in proof slot 1 (local Semaphore tasks 439 dry run and 440 real run of Deploy Plane (Local) at f918098b3):

  • The mail setting keys and which one is encrypted (EMAIL_HOST_PASSWORD), from InstanceConfiguration.
  • ENABLE_SMTP is stored as the string 0, and Plane's own disable endpoint writes 0.
  • The sender reads those database rows, decrypting encrypted ones, because settings.SKIP_ENV_VAR is true in the worker and the API.
  • test_email.py takes one recipient, sends subject Test email, prints Email successfully sent on success and an Error: line with exit 0 on failure.
  • EMAIL_BACKEND is django.core.mail.backends.smtp.EmailBackend on Django 5.2.16, whose STARTTLS context is ssl.create_default_context(), so the relay's certificate and name are verified.
  • The worker was on plane_default only.

Tests

  • New platform/tests/test_plane_outbound_mail.py (39 tests, 4 ansible-playbook runs; uv run --locked pytest platform/tests/test_plane_outbound_mail.py -q passed 38 in 12 s on c8c6cdb59, and --collect-only lists 39 on 85dde792d): mail off for unset, false, 0, blank and null; the exact eight settings; every smtp_starttls spelling; the listed read only while mail is on; worker selection with near-misses; the test-mail judgement with near-misses; static checks on guard order, block gate, task order and the compose network.
  • test_the_catcher_inputs_are_set_only_as_the_include_vars_of_the_catcher_check (added on 7fa5cc9d): the four mail_captured_* inputs are include vars of the one catcher task, and no play var, block var, set_fact or register defines any mail_captured_ name. A play-var, a set_fact and a register mutant each turned it red, each restored. The shared task's extra-var refusal lands in feat(authentik): send outbound mail through the shared SMTP settings [AC-1125] #1247, which merges first.
  • CI fix on c7e0a310: Python (2/8) failed test_play_vars_scope.py::test_no_play_reads_another_plays_vars on c8c6cdb5, because Phase 4 read _deploy_dir only through the fact an included task sets. Phase 4 declares it again, with the same formula as tasks/list-service-containers.yml (85dde792). Recorded as a docs/MISTAKES.md 5.2 repeat.
  • platform/tests/test_service_plane.bats: one pin updated for the new _shared_reads text.
  • Not re-run in the current session (the earlier owner session ran them on this test file): mutations, each restored, each turning named cases red: worker label equality made a substring search; the exact success line made a substring search; the mail-on gate on the token read removed; the Phase 3 guard removed; the stubbed send skipped.

Local proof

Not verified: the local proof has not run. The local stack is down after the reboot of 2026-11-28 and the coordinator holds proof slots until it is rebuilt. The dry run and real run of platform/playbooks/deploy-plane.yml through ./scripts/local-dev.sh run, the catcher check and the second run with no settings change are added here, with their local task ids, when a slot runs.

Review passes

  • /simplify round 1 on d78913d2b: tests moved to the shared runner and batched from 41 runs to 4, dead Phase 4 variables removed. Round 2 on 5c569f2b6: the send cases now prove the stubbed command ran. Deferred, until unit S4 adds the second caller: a shared local mail-check task (AC-1225) and a shared mail-on filter (AC-1226).
  • /security-review on 5c569f2b6: no findings at threshold. The STARTTLS certificate question it raised is answered above.
  • Head 85dde792d: /simplify on 30e446fc5 (the CI fix, the new test and the ledger note) merged the two Phase 4 path variables into one with the shared fact's formula and a reason comment, and flattened the new test's walk (85dde792d). Skipped: reusing playbook_yaml.defined_names, which records no task identity, so it cannot pin the one owning task. /security-review on 85dde792d: no findings.

Lesson

docs/LESSONS.md L-038 (added in 4e4c573, after the refresh against dev at ef8dd1e): Plane's manage.py test_email exits 0 when delivery fails, so a task that sends a test mail through it checks for the line Email successfully sent in its output and then the delivery itself, never the exit code alone.

…127]

With smtp_host set in the inventory, Phase 3 writes Plane's outbound mail instance settings
(ENABLE_SMTP and the EMAIL_* keys) from the inventory's SMTP values and the mail token read from
secret/services/smtp:plane_smtp_token. The token is read only while mail is on, as a listed read
that fails the run when the key is missing. With mail off no mail key is sent and nothing is cleared.

The SMTP guard is the first task of Phases 1, 3 and 4. The local-dev Plane worker joins the local-dev
network so it can reach the local mail catcher. The production inventory is unchanged, so mail stays off
there.
…l judgement [AC-1127]

The new tests run the expressions and tasks of deploy-plane.yml as written. They cover the settings
for each spelling of smtp_host and smtp_starttls, the listed read in each combination of Authentik and
mail, the worker selection by compose service label, the exact success line of the test mail, and the
play and task order of the Phase 4 local mail check. Nothing reaches a container, a mail server or the
network: the worker listing and the test-mail command are stubbed, and every value is a placeholder.
….md rows [AC-1127]

The Plane deployment notes gain an Outbound mail section: the settings written, the mail-on gate, the
token path, and the local verification. AGENTS.md records that Deploy Plane now reads plane_smtp_token
through _shared_reads while mail is on, and that the Authentik and Grafana deploys do not read theirs yet.
…lready sets [AC-1127]

The Phase 4 play defined _monorepo_dir and _deploy_dir as play vars. No task in the play reads
_monorepo_dir. The one task that reads _deploy_dir gets it from the fact that
tasks/list-service-containers.yml sets earlier in the play, during the containers-stable check,
so the play vars were not needed. The one remaining reader gets a comment naming where the fact
comes from.
…roup [AC-1127]

Each group of Plane's outbound mail cases now runs as one ansible-playbook run instead of one run
per case. The Phase 3 mail settings and the converge stdin, the Phase 1 listed reads, the worker
selection and the test-mail judgement each run once over one host per case. Every case still has
its own test, and that test reads only its own host's result, so a red case names itself. The file
went from 41 ansible-playbook runs to 4, and its run time from about 29 seconds to about 7 seconds.

The mail-off converge test is folded into the converge test, parametrised over mail on and mail
off. The converge test now checks the exact settings each stdin renders, in place of a second run
that compared against a combined rendering. The send group's run also marks the time before the
test mail, so the since-time test reads that value from the same run. Every case and near-miss from
before keeps a test, and the static tests still read the playbook without running it.
…t [AC-1127]

Each send case now also checks the stub's exit status and output lines, so a case that judges a
failed send can no longer pass because the command never ran. The mail block's gate is compared
as a set of conditions, so reordering them is not a failure.
@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 8 billable files and costs up to $2.00.

  • Add your request for automatic reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 2 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available. Your 52 included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between ef8dd1e and 4e4c573.

Files selected for processing: 8

  • AGENTS.md
  • docs/LESSONS.md
  • docs/MISTAKES.md
  • platform/playbooks/deploy-plane.yml
  • platform/services/plane/deployment/CLAUDE.md
  • platform/services/plane/deployment/compose.local.yml
  • platform/tests/test_plane_outbound_mail.py
  • platform/tests/test_service_plane.bats
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@jestyr27

Copy link
Copy Markdown
Member Author

simplify: deferred
platform/playbooks/deploy-plane.yml:732 the local mail check's container discovery, since-mark and catcher include are generic; extract a shared task when unit S4 adds the second caller (AC-1225)
platform/playbooks/deploy-plane.yml:139 the mail-on expression is repeated here, at :233 and :734, and in platform/playbooks/tasks/assert-smtp-settings.yml:50 and :61; replace with one filter when unit S4 adds the next caller (AC-1226)

@uhstray-io-plane-github

Copy link
Copy Markdown

Reverts 210720a. The local mail check reads _deploy_dir, which that commit left to the fact
tasks/list-service-containers.yml sets inside the containers-stable include. The play-vars scope
guard (test_play_vars_scope.py) does not scan included task files, so it read _deploy_dir as
another play's var and failed CI on #1249 (Python 2/8). Defining it in Phase 4's own vars keeps
the read visible to the guard and independent of the include's order.
…lude vars [AC-1127]

assert-mail-captured.yml takes its inputs as include vars or play vars. The test pins that
deploy-plane.yml defines the four it passes only as include vars of the one catcher task, with no
play var, block var, set_fact or register of any mail_captured_ name, so the shared task's
extra-var refusal (landing in #1247) covers every source. A play-var mutant and a set_fact mutant
each turn it red.
…a [AC-1127]

Phase 4 declared _monorepo_dir and _deploy_dir from the Phase 1 pattern, without the
compose_working_dir branch that tasks/list-service-containers.yml uses for the fact that replaces
it after the containers-stable include. One variable now carries that same formula and a comment
saying it exists because the play-vars scope guard does not follow includes. The catcher-inputs
test walks each node's names in one flat list.
@jestyr27

Copy link
Copy Markdown
Member Author

review: approved on 85dde792d52e0e76077c9f65742155166abef133 (independent pr-reviewer round; CodeRabbit was rate-limited on this pull request)

No blocking finding. Checked on this head: the eight settings and their string values (platform/playbooks/deploy-plane.yml:232-241), the mail-on gate matching the guard (:139, :233, :741), no token read and no mail key while mail is off, the token only inside the stdin of the no_log configuration task, the guard first in Phases 1, 3 and 4, check mode writing nothing, and _deploy_dir using the formula of platform/playbooks/tasks/list-service-containers.yml:23-26. Mutations of the token gate, the | bool, the default('', true), the worker label equality and the exact success line each turned tests red.

Two low findings, both in platform/services/plane/deployment/CLAUDE.md, both to be fixed in the refresh on dev after #1247 merges, so the final head carries them:

  1. platform/services/plane/deployment/CLAUDE.md:156 says a blank smtp_host turns mail off. The guard counts only an exactly empty string as off (platform/playbooks/tasks/assert-smtp-settings.yml:10-13) and refuses whitespace as malformed (:37). The line will say "an empty string", and that a value of only spaces is refused.
  2. platform/services/plane/deployment/CLAUDE.md:159-165 does not say that a local Plane deploy needs Mailpit running: the local inventory turns mail on for every local host (platform/playbooks/bootstrap-local-dev.yml:1309-1314), and the verify's test mail fails when the catcher is down. The section will say to deploy Mailpit first.

Not verified in this round: the Plane v3.3.3 setting names, the stored form of ENABLE_SMTP, the test_email success line and subject, and an unchanged second run. They wait for the local proof; a wrong name or line fails the run, it cannot pass silently (platform/services/plane/deployment/configure_instance.py:41-43).

@jestyr27

jestyr27 commented Dec 3, 2026

Copy link
Copy Markdown
Member Author

owner check: head 4e4c573

Review. The one review round, on 85dde79, approved (PR comment of 2026-11-29T00:27:30Z, starting review: approved on 85dde792…). No return is open. Case (b) of "a head that keeps its review" does not hold, because the merge left files in conflict, so this head does not keep that round. This comment is the owner's check of the head instead.

What changed since the reviewed head.

  1. Merge commit 5f7b09b (parents 85dde79 and ef8dd1e) merges dev at ef8dd1e into the branch.
  2. Commit 4e4c573 adds lesson L-038 to docs/LESSONS.md: Plane's test-mail command exits 0 on a failed send.

How the two conflicts were resolved.

  • AGENTS.md: dev's two new weft rows of the OpenBao secrets table are kept (lines 255 and 256). This pull request's secret/services/smtp row follows them on line 257, byte for byte the row the review read.
  • docs/MISTAKES.md: both sides are kept, and none of dev's entries is renumbered. In entry 5.2, this pull request's 2026-11-28 occurrence (a play variable past the play-vars scope guard) sits after dev's 2026-11-28 occurrence and before dev's 2026-11-29 ones. The 5.2 Index row carries both 2026-11-28 notes, and its count is 23: dev (ef8dd1e) has 22, and this pull request's repeat adds one.

Case (b) commands and their whole output.

$ git merge-base --is-ancestor ef8dd1e25cd65e575de3591d705dee3483b236a4 refs/remotes/origin/dev
exit=0
$ git merge-tree --write-tree --name-only 85dde792d52e0e76077c9f65742155166abef133 ef8dd1e25cd65e575de3591d705dee3483b236a4
exit=1
e58ce1f30693af39f99479f2f9645a94d2b4c0eb
AGENTS.md
docs/MISTAKES.md

Auto-merging AGENTS.md
CONFLICT (content): Merge conflict in AGENTS.md
Auto-merging docs/MISTAKES.md
CONFLICT (content): Merge conflict in docs/MISTAKES.md
$ git diff --name-only --no-renames e58ce1f30693af39f99479f2f9645a94d2b4c0eb 4e4c573d53e0d94aaa5b2d70745e21ea53709a0e
AGENTS.md
docs/LESSONS.md
docs/MISTAKES.md
exit=0
$ git diff --numstat --no-renames $(git merge-base 4e4c573d53e0d94aaa5b2d70745e21ea53709a0e refs/remotes/origin/dev) 4e4c573d53e0d94aaa5b2d70745e21ea53709a0e -- docs/LESSONS.md
6	0	docs/LESSONS.md
exit=0

Against the merge tree, the head changes only AGENTS.md (the conflict resolution above), docs/LESSONS.md (six added lines, none removed) and docs/MISTAKES.md (the conflict resolution above).

The unit's own files are unchanged since the reviewed head.

$ git diff --name-only --no-renames 85dde792d52e0e76077c9f65742155166abef133 4e4c573d53e0d94aaa5b2d70745e21ea53709a0e -- platform/playbooks/deploy-plane.yml platform/services/plane platform/tests/test_service_plane.bats platform/tests/test_plane_outbound_mail.py platform/tests/test_plane_configure_instance.py

exit=0

Checks.

  • The pre-push hook passed on this head: BATS 883 ok with none failing, the pytest fast lane 5369 passed with 2 skipped, and the Rust push lane 1069 passed.
  • The simplify and security-review statuses are posted on this head as covered by the round on 85dde79.
  • CI on this head was still running when this comment was posted.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant