# Prepared newsletter output and immutable local delivery images

Decision revision5 extends accepted lifecycle/media commit04db2b67. This is a
LOCAL contributor. Feature defaults remain off, existing newsletters retain their
format, and unselected companies keep the legacy editor. No live activation,
production migration, mail delivery or external client qualification occurred.

## Saved preparation and format identity

The explicit prepare action requires the original page actor/company context,
existing edit plus create permission, an enabled allowlisted company, the current
saved revision and a UUID intent. The server selects source ownership, saved
content/name, compiled artifacts, newsletter identity and the opaque asset handles.
Unsaved local edits remain on the page and are excluded. Preparation does not send.

A company/actor/intent uniqueness constraint and request fingerprint prevent
duplicate committed snapshots. A matching retry returns the original snapshot;
a changed fingerprint returns409. Current draft locking protects revision checks.
Concurrent MySQL behavior is a separate gate: an overlapping unique-constraint
failure may be ambiguous and requires reopening, never automatic replay.

The server writes a normal newsletter row with explicit
templatical-output-v1/editor_output_id identity and an immutable output record.
Legacy editor update/copy routes refuse this format instead of interpreting its
empty legacy JSON. The editable source/history remain independent and immutable
historical snapshots are not rewritten. Output history is tenant-scoped, paginated
20 per page and contains metadata only. Prepared HTML requires authenticated
newsletterParse permission and an available company.

The supported URLs are exactly {{unsubscribe_url}} and {{online_url}}, each in an
entire anchor destination. Unknown merge/privacy tokens, text-position tokens and
tokens embedded in another URL are refused with localized actionable guidance.
Nuhet has a separate type99 GDPR consent workflow; this change does not invent a
generic GDPR policy/merge field. Use an explicit published canonical HTTPS privacy
policy link. New starter content uses the known online URL; existing drafts are
preserved and receive a refusal if their unsupported tokens remain.

## Immutable delivery assets and rollback

Existing own-library references are authorized and revalidated against current
company media rows, canonical non-symlink paths, raster bytes, MIME and dimensions.
Only PNG/JPEG/GIF/WebP qualify. Limits are5MiB per image,20 unique owned images and
20MiB per prepared output. The private library files are never modified.

Validated bytes are copied to the existing local newsletter disk under
editor-delivery/<company>/<random256-bit-handle>. Public routes accept only opaque
handles, verify output/newsletter/company linkage, actual byte size/hash/raster MIME
and dimensions, and return only raster bytes. There is no arbitrary fetch, remote
import, upload, provider or public HTML/tenant metadata route. Delivery URLs derive
from configured canonical app origin, never caller Host. Deployment must qualify
that configured HTTPS origin and persistent storage before activation.

External canonical HTTPS images retain the existing external-reference contract.
Their URLs are recorded separately; their bytes are neither fetched, vetted nor
made immutable by Nuhet. Deletion/mutation of such remote content is outside this
snapshot guarantee.

Prepare compiles ONCE after owned-byte remapping. It stores normalized JSON,
pipeline provenance, source hash, HTML/text and their hashes. Reader/test/scheduled
paths load that saved base; no mutable-draft compiler runs at delivery time.
Prepared preview retains unresolved recipient URLs in the saved base; test mail
uses existing disabled-link semantics. Real recipient delivery applies the
canonical subscription/online/tracking substitutions and HTML escaping through
NewsletterScanner. MIME capture verifies consumed HTML/text against actual queue
bodies; base hashes remain identical before these explicit context substitutions.

Turning the authoring flag off does not disable already-prepared readers/assets.
The additive migration's down operation deliberately preserves reader data.
This is FEATURE-FLAG rollback safety, not permission to remove schema or deploy
an old binary without the new reader. Retain compatible reader code and assets
while any prepared newsletter may be consumed. Client-cached copies cannot be
recalled: asset responses require application revalidation, but retention does
not promise erasure from recipients' mail clients.

## Cleanup and retention

Staged files are reconciled under a fresh exclusive company-availability lock.
A database row is proof to preserve a handle after uncertain commit acknowledgment.
If database reconciliation is unavailable, private orphans remain for later
explicit cleanup; do not assume rollback or delete possible committed assets.
Explicit orphan cleanup accepts only the known canonical namespace/handle format,
removes only unreferenced files and fails closed on unknown entries/symlinks.
There is no invented automatic expiry.

CompanyPurgePreflight checks output/newsletter/asset/draft/copy ownership before
the existing leased CompanyDataPurger removes the new footprint. Company marking
retains data; public reads stop while unavailable. The existing policy retains
exactly12 calendar months and permits purge strictly afterward under its existing
switch and lease. No production purge scheduler or duration was changed.
SQLite tests cover lease enforcement, exact anniversary, reference preservation,
full existing purger integration and foreign sentinel survival. MySQL races,
arbitrary process interruption and production operational retry remain release gates. Deterministic after-unlink failure/explicit retry and exact1000/1001 local qualification are documented in newsletter-editor-operational-3967.md.
Current conservative per-company file scan is bounded1000; larger real footprints
require explicit batching/qualification before purge, not a silent partial erase.

## Local verification and remaining product inputs

The separate verify-output.mjs runs with guarded disposable SQLite aliases,
file sessions, synthetic authentication, owned loopback HTTPS and actual app
routes. Effective legacy/new mail configuration is pinned to ArrayTransport,
and an actual MessageSending boundary guard asserts the effective transport and
exact synthetic sender/recipient. A legacy-driver override counterexample fails
before a transport call. No SMTP/network mail or unguarded queue worker runs.

It exercises Sv/En library selection, keyboard save and preparation, saved-name
readback, unsaved edits, immutable prepared preview, anonymous cookie-free image
rendering, source mutation/deletion and authoring rollback, real test-handler and
scheduled dispatcher/final QueueMailer consumption at a fake destination, consent
refusal, desktop/820px and phone saved history/preview. Full entry proof is limited
to EMPTY synthetic legacy/v2 indexes and discloses existing Angular errors.
Phone authoring remains the default SDK small-screen notice, not accepted mobile
authoring. Self-signed local TLS, synthetic login and SQLite are not production
TLS/login/MySQL or inbox-rendering proof.

Repo-owned socialmedia/video render partials exist under both editor element
renderTemplate trees. They are legacy component contracts, not three complete
sanitized Nuhet newsletters. The supplied pipeline fixture uses supported seven
block types and an existing project logo; it is NOT a representative real customer
template. Root needs three sanitized complete source newsletters with expected
content/links/media and social/video fallback expectations. No arbitrary HTML/video
support was added to accommodate the missing input.

Before a real-mail/client step, obtain a separate root-approved packet:
- Three sanitized finalized representative outputs and expected recipient link
  behavior; owned/library assets and external references identified.
- Named test inboxes/owners and approved access method for Outlook desktop/web,
  Gmail web/mobile and Apple Mail/iOS (agree the final required client versions).
- Proposed bounded send count:3 representative messages per distinct approved
  inbox, with explicit recipient addresses and subjects; no real customer list.
- Light/dark, images loaded/blocked, desktop/mobile width, links/unsubscribe/online,
  text alternative and accessibility observations recorded per client/message.
- Authority for those exact sends and client access, any service/license cost,
  test-content approval, cleanup/retention owner and time window.
No such external action or paid service is approved by this LOCAL contributor.
Final phone/pilot, fresh target integration/upstream, MySQL and release gates remain
with root. The full card stays open.