Legal 0.7.0: Support for core 3 and a repair manifest for consent logs
Legal 0.7.0 makes PhoenixKit’s legal module work with core 3. The module now describes its consent log table itself, so mix phoenix_kit.repair and mix phoenix_kit.doctor can check it again.
Core 3.0 no longer creates module tables; Legal’s own migration chain builds phoenix_kit_consent_logs. The new manifest, PhoenixKit.Modules.Legal.ExpectedSchema, is generated from that chain. Repair uses it to create what is missing and reports anything else, and it checks the table only while the database is at the chain’s current version. Core reads the manifest from the first release after 2.64.1.
Nothing changes in the admin, the cookie banner or the generated pages.
Upgrading
Legal 0.7 accepts PhoenixKit core from 2.65.0 up to, but not including, 4.0, and needs Publishing 0.15 or later. No migration.
Full release notes: Legal 0.7.0
0.7.0 · 27 October 2026
Changed
- Core pin widened to
>= 2.65.0 and < 4.0.0: works with core 3.x (core 3.0 stops creating the module tables; this module’s own chain builds its tables). The floor is the first core with thefile_references/0andexpected_schema/0callbacks, which now carry@impl PhoenixKit.Module.
Fixed
-
css_sources/0no longer emits the same directory twice. On a normal Hex install the callback returned both:phoenix_kit_legaland a compile-time absolute source root, and the host’s generatedassets/css/_phoenix_kit_sources.csscame out with two directives pointing at one directory:@source "../../deps/phoenix_kit_legal"; @source "/www/app/deps/phoenix_kit_legal";The absolute entry was added deliberately in 0.1.9 so
path:deps resolve, on the stated assumption that the pair collapses for Hex installs. It doesn’t:Mix.Tasks.Compile.PhoenixKitCssSourcesrunsEnum.uniq/1over the raw callback results — an atom and a string, never equal — and formats them into path strings only afterwards. No other PhoenixKit module returned an absolute root, so Legal was the only duplicated entry.Effects were cosmetic in the common case (Tailwind scanned the directory twice, and the file is regenerated every compile so it self-corrects per machine), but the absolute path is baked in when this dep is compiled, which made a generated file host-specific: git churn if it is committed, and a
@sourcethat matches nothing if_buildis carried across a path change, such as a multi-stage Docker build that compiles under one prefix and runs under another.The absolute root is now returned only when it is not already what the
:phoenix_kit_legalentry resolves to. Path deps, umbrellas, and vendored checkouts keep the fallback; standard installs get one directive. -
The comment justifying the old behaviour said the compiler de-duplicated the pair via
Enum.uniq/1. It reads on the wrong side of the formatting step. Replaced with the actual ordering, so the claim is checkable againstcompile.phoenix_kit_css_sources.ex.
Added
- The module supplies the manifest of its 1 tables (
expected_schema/0,PhoenixKit.Modules.Legal.ExpectedSchema), somix phoenix_kit.repairandmix phoenix_kit.doctorcheck and repair them again, now from the module’s own chain instead of core’s manifest. Generated fromPhoenixKit.Modules.Legal.Migrationsby core’sdev_docs/squash/generate_module_manifest.exs, never edited by hand. Core uses it from the first release after 2.64.1; before that nothing reads it. Repair is additive (it creates what is missing and reports the rest) and checks the tables only while the database is at the chain’s current version. No migration. test/phoenix_kit_legal/css_sources_test.exs— pins the deps/, path-dep, and umbrella layouts, and assertscss_sources/0never lists a directory the atom entry already covers.
0.1.10 (2026-08-03)
Removed
-
PhoenixKitWeb.Controllers.ConsentConfigController— core owns the consent-config endpoint now. (#12, by @mdon; pairs with phoenix_kit#677)GET /phoenix_kit/api/consent-configwas always routed by core, not by this package — core declared the route and picked the controller’s module name, and this package supplied a module to match it. That only worked while core declared the route conditionally on this package being loaded: an install without it answeredPhoenix.Router.NoRouteError, because the vendored JS bundle asks for the endpoint whether or not Legal is installed.Core now declares the route unconditionally and answers it itself, with 204 when this package is absent and the usual JSON — delegated to
Legal.get_consent_widget_config/0— when it is present. Nothing here referenced the controller, and the endpoint’s behaviour with Legal installed is unchanged.
Changed
-
{:phoenix_kit, "~> 1.7.189"}→{:phoenix_kit, "~> 1.7.227"}. This is a hard requirement of the removal above, not a routine bump. Core declares the consent-config route wheneverPhoenixKit.Modules.Legalis loaded, and before 1.7.227 that route points at the controller this package used to define. On an older core the route would resolve to a module that exists nowhere and raiseUndefinedFunctionError— a logged 500 on every page load where the widget was not server-rendered, which includes authenticated users (legal_hide_for_authenticateddefaults totrue). Phoenix compiles routes to literal tuples, so nothing would have warned at compile time.Upgrading from 0.1.9 or earlier requires
phoenix_kit1.7.227+. The reverse order is safe: core 1.7.227 with legal ≤ 0.1.9 simply leaves this package’s old controller unused, since core’s is deliberately namedPhoenixKitWeb.Controllers.ConsentConfigrather than reusing the published name.
Documentation
- README and AGENTS.md no longer list the deleted controller, and the “API Endpoint”
section now says who owns the route. Its cache header was documented as “cached
publicly for 60 seconds” — stale since it became
private, max-age=60, which is deliberate: the payload embeds locale-dependent translations, so it is cacheable per user but must never be shared. - AGENTS.md gains a “Consent Config Endpoint Contract” section recording the
ownership split and the release-ordering rule, next to the existing
reserved_route_prefixes/0note.
0.1.9 (2026-07-25)
Fixed
-
publish_page/2silently did nothing — pages stayed drafts and kept 404ing, including via the admin “Publish” button. (#11, reported by @timujinne)It published by calling
Publishing.update_post/4with%{"status" => "published"}. Publishing deliberately refuses that write —deferred_publish_status/1drops a"published"value, because the status andactive_version_uuidmust be set in one transaction; splitting them let a save commitstatus=publishedwhile the paired publish rolled back, leaving a post that reads published with no active version.Versions.publish_version/4is that transaction, andpublish_page/2never called it.So the version stayed
draft,active_version_uuidstayedNULL, and Publishing’s public dispatch — which serves only posts with an active version — returned 404.update_post/4still succeeded, sopublish_page/2returned{:ok, post}and the admin flashed “Page published successfully”. Nothing surfaced the failure.publish_page/2now callspublish_version/4on the post’s current version, matching how Publishing’s own admin publishes (Web.Listing.apply_status_change/4).This was the remaining reason
/legal/:slug404’d after the 0.1.7 routing fix. The two are independent: 0.1.7 restored the route, and a page still had to be genuinely published to be served. Anyone who published via the admin button orpublish_page/2had pages that were never published at all.
Added
publish_page/2accepts a:versionoption to publish a specific version; it defaults to the post’s current version.
Changed
publish_page/2re-reads the post after publishing, so the returned{:ok, post}carries the post-publish state rather than the pre-publish one. The return contract is unchanged.- The audit trail now records the acting user.
publish_version/4audits by:actor_uuidand ignores the:scopethatupdate_post/4accepts, so the scope callers pass is resolved to a user uuid rather than dropped. - Admin settings read the correct scope assign.
Web.Settingspassedscope: socket.assigns[:current_scope]for all three actions (generate, publish, generate all), but PhoenixKit mounts the scope as:phoenix_kit_current_scope(PhoenixKitWeb.Users.Auth), so the value was alwaysniland every admin action logged anilactor. Pre-existing, and it would have made the audit-trail improvement above a no-op for the admin UI — the only place most people publish from. Found in independent review of this release. - Corrected the stale
phoenix_kit ~> 1.7.170dependency note inPhoenixKitLegal’s moduledoc;mix.exshas required~> 1.7.189since 0.1.6.
0.1.8 (2026-07-25)
Documentation and packaging follow-up to 0.1.7. No behaviour changes — the
/legal routing fix itself shipped in 0.1.7 and is unchanged here.
Fixed
- HexDocs “Source” links 404’d on every release.
docs.source_refwas"v#{@version}", but this repo’s tags are bare version numbers (0.1.7, notv0.1.7) as documented inAGENTS.md— so every source link pointed at a tag that has never existed. Now@version. - ExDoc reference to
c:PhoenixKit.Module.reserved_route_prefixes/0in the 0.1.6 entry below was written as a function; it is a@callback, which ExDoc resolves only via thec:prefix.mix docsis now warning-free.
Added
- Upgrade guide — new “Upgrading” section in
README.mdand “Upgrade notes” under 0.1.7 below: the commands to run, how to verify, the two reasons a page can still 404 afterwards (pages left indraft, or a leftover/legalroute from the 0.1.6 workaround), and what is deliberately not required (no new migration, no cache clearing, no config or router changes).
0.1.7 (2026-07-25)
Fixed
-
Public legal pages 404’d on every host app that hadn’t hand-written a
/legalLiveView. 0.1.6 addedreserved_route_prefixes/0returning["legal"], which tellsphoenix_kit_publishing‘s catch-all dispatch to leave/legalalone so a host-app LiveView can own it. No such LiveView ships with this module, none is generated bymix phoenix_kit_legal.install, and none was documented — so for any host that didn’t happen to have one, the reservation removed/legaland/legal/:slugfrom Publishing’s dispatch without anything taking over. Pages that had been rendering since the module shipped started returning 404, including the links the cookie consent widget shows to every visitor.The reservation was introduced to fix a real SEO defect — publishing-served pages canonicalized to
"/"because the public controller never assigned:url_path, and Google dropped them as duplicates. That defect was fixed at its source inphoenix_kit_publishing0.2.3 by theassign_url_pathplug inWeb.Controller, which shipped the same day (PRs #27–#29). With canonical /og:url/ hreflang now correct on publishing-served pages, the reservation had no remaining benefit and only the 404 cost.
Changed
- Legal no longer implements
reserved_route_prefixes/0— it falls back to the behaviour’s[]default. Generated pages are served by Publishing’s/:language/:group/*pathdispatch at/legaland/legal/:slug, with language prefixes, translations, and in-place editing handled like any other Publishing group. This restores the module’s original division of labour: Legal generates content, Publishing renders it. No host-app action is required — remove any/legalroute added to work around 0.1.6. - Documented the public-page contract in
README.md(new “Public Legal Pages” section) andAGENTS.md. Its absence is what made the 0.1.6 regression hard to diagnose: the only written trace of the routing rule was a source comment inphoenix_kit_publishing’srouter_dispatch.ex.
Upgrade notes
mix deps.update phoenix_kit_legal phoenix_kit_publishing
mix phoenix_kit.update # apply any pending schema migrations
# restart the app
Requires phoenix_kit ~> 1.7.189 (both modules), and
phoenix_kit_publishing ~> 0.4.4 for the matching README documentation. Verify
with curl -I https://yoursite/legal — expect 200, not 404.
If it still 404s, two causes, in order of likelihood:
- Pages are still drafts. Upgrading publishes nothing. Publishing 404s
unpublished posts for anonymous visitors, so a page generated but never
published stays invisible. Publish from
/admin/settings/legal, or checkLegal.all_required_pages_published?/0. - A leftover
/legalroute from the 0.1.6 workaround. Delete it — Publishing’s dispatch rewrites the path in the router’scall/2before route matching, so the route is unreachable regardless of its position inrouter.ex.
Not required: no new migration (the phoenix_kit_consent_logs schema is
unchanged — mix phoenix_kit.update is listed only because it’s idempotent and
catches pending core migrations), no cache clearing (group-slug resolution is a
live per-request DB lookup and reserved prefixes are recomputed per call), and no
config, settings, or router changes. Run mix phoenix_kit.assets.rebuild only if
the consent widget renders unstyled.
0.1.6 (2026-07-03)
Added
reserved_route_prefixes/0(@impl PhoenixKit.Module) declares"legal"as a reserved top-level route prefix, so Publishing’s/:language/:group/*pathcatch-all dispatch can be told to leave the host app’s own/legalroute alone instead of treating the"legal"Publishing group Legal creates as one of its own groups. Requiresphoenix_kit≥ 1.7.170 (adds the callback) and aphoenix_kit_publishingrelease that consultsPhoenixKit.ModuleRegistry.all_reserved_route_prefixes/0in its dispatcher — declaring the prefix here is a no-op until both are in place. (#9)
Changed
- Bumped
phoenix_kitdependency floor to~> 1.7.170— the version that introducesc:PhoenixKit.Module.reserved_route_prefixes/0, which this module now implements under@impl.
0.1.5 (2026-05-22)
Fixed
Migrations.ConsentLogsnow implements the versioned-migration protocol PhoenixKit Core v1.7.119 (schema V121) expects —current_version/0andmigrated_version_runtime/1— andup/1/down/1accept the keyword list Core passes (prefix:,version:) as well as the legacy map. Previously, on a clean install against the new Core,mix phoenix_kit.updatesilently skipped the Legal migration andphoenix_kit_consent_logswas never created (existing installs were unaffected). (#8)
Changed
- Translated the
ConsentLogsmigration’s docstrings and comments to English (no logic or SQL change)
0.1.4 (2026-05-09)
Changed
- All module-owned
gettextcalls now resolve throughPhoenixKit.Modules.Legal.Gettextinstead of the parent app’sPhoenixKitWeb.Gettext— completes the per-module-i18n migration started in 0.1.3 (legal.ex,web/cookie_consent.ex,web/settings.ex) translate_title/2resolves page titles against the module’s own catalogue underpriv/gettext/, so generated legal pages get titles in the user’s locale even on parent apps that don’t translate these strings themselvespriv/gettext/default.potis now auto-extracted (mix gettext.extract --merge) — covers tab labels, page titles, consent-widget UI, and admin flash messages (126 msgids);__extract_strings__/0seeds runtime-only strings for the extractor
Added
- Russian (
ru) and Estonian (et) translations for the entire catalogue: consent-widget banner / modal / category names, page titles, settings labels, flash messages Plural-Formsheader onpriv/gettext/en/LC_MESSAGES/default.po- Per-locale tests for the module’s own catalogue (
translate/2smoke tests covering page titles + consent-widget strings) — runnable against anyphoenix_kitrelease; tab-label tests remain gated behind:requires_phoenix_kit_i18n_apiuntil BeamLabEU/phoenix_kit#522 ships
Notes
- Sidebar tab label still falls back to the raw “Legal” string on
phoenix_kit≤ 1.7.105:Tab.localized_label/1and thegettext_backend:field on%Tab{}ship with phoenix_kit#522, which is unmerged. Consent-widget strings and page titles already resolve per-locale on the publishedphoenix_kitbecause they’re rendered live from our own modules.
0.1.3 (2026-04-30)
Added
mix phoenix_kit_legal.installtask — auto-patches host app’sendpoint.ex(Plug.Static),assets/css/app.css(Tailwind@source), andassets/js/app.js(consent IIFE import); idempotentmigration_module/0callback returningPhoenixKit.Modules.Legal.Migrations.ConsentLogs— migration runs viamix phoenix_kit.update- i18n:
Legal.get_consent_widget_config/0returns atranslationsmap (banner / modal / categories); JS reads viat()/tc()helpers with English fallbacks - Legal page titles translated at generation time via
Gettext.with_locale/3so per-language Publishing slots receive the title in the right language - New
phoenix_kit_current_scopeattr oncookie_consent/1— component decides server-side whether to render for authenticated users
Changed
- Server-side auth gate for cookie consent widget:
cookie_consent/1now returns~H""for authenticated users whenhide_for_authenticated?is true, eliminating the client-side flash and the auth round-trip - Default for
legal_hide_for_authenticatedflipped fromfalsetotrue— existing installs that want the widget visible to authenticated users must set this explicitly in Admin → Legal /api/consent-configcache header changed frompublic, max-age=60toprivate, max-age=60(translations are locale-dependent)- Locale prefix dropped from widget links (
/en/legal→/legal) so the parent app’s locale plug picks the user’s current locale on click css_sources/0returns[:phoenix_kit_legal, @source_root]— absolute source root included for path-dep installs
Removed
should_show,is_authenticated,hide_for_authenticatedfields from/api/consent-configJSON response — auth-gating is now server-side onlyresetGoogleConsentModeJS helper — over-broad heuristic, removed
Fixed
- Banner and modal no longer hidden by Tailwind’s
hiddenclass!important - Consent widget initializes reliably from
DOMContentLoadedoutside LiveView scope - Server-rendered consent HTML preserved (no JS re-injection layout flicker)
- HTML escaping (
escapeAttr/escapeText) applied to user-controlled URLs and translation strings in the JS injection path - Component accepts
cookie_policy_url/privacy_policy_url/legal_linksagain as no-op attrs for backward compatibility with PhoenixKit default layouts
Internal
- Test infrastructure:
test_helper.exsstartsPhoenixKit.Cache.Registryand:settingscache for component tests - Credo
--strictclean (resolved 5 nested-module references in tests, 1 single-branchcond, 1 deeply-nested function) - Dialyzer clean (
:mixadded toplt_add_apps)
Migration notes
- Recommended (not required): add
phoenix_kit_current_scope={@phoenix_kit_current_scope}to your<.cookie_consent ...>call so the “Hide for authenticated users” admin setting takes effect. Without it the widget renders for everyone.
0.1.2 (2026-04-05)
- Fix Legal settings route 404 by adding missing
live_viewfield to settings tab definition - Add
version/0callback to display actual package version on modules page - Add
elixirc_options: [ignore_module_conflict: true]for umbrella compatibility - Update dependencies to latest versions
0.1.1 (2026-04-02)
- Migrate select elements to daisyUI 5 label wrapper pattern
- Remove deprecated
select-borderedclass for daisyUI 5 compatibility - Add
live_viewto settings tab for auto route discovery - Add
css_sources/0callback - Fix legal page generation for existing/trashed posts
0.1.0 (2026-03-27)
- Initial extraction from PhoenixKit core
- Legal page generation (Privacy Policy, Cookie Policy, Terms of Service, etc.)
- Cookie consent widget with Google Consent Mode v2
- GDPR, CCPA, LGPD, PIPEDA compliance frameworks
- Consent logging schema
Legal 0.7.0. Install or update: {:phoenix_kit_legal, "~> 0.7"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.