Skip to content

The Rails CMS: what the platform still owes

What the deleted Rails fleet CMS (rails/) did that the platform does not do yet — one section per open capability, with what Rails did, where the platform stands and what to build — so the code could go while its behaviour stays specified.

The owner deleted rails/ on 2026-10-27 (ADR 0008), after merging the branches that had already ported most of it: G4 (overhaul/sites-jobs at 61213c00: the catalog, front-matter surgery, the confined writer, the site registry, sync, write-back and the doctor) and G5 (overhaul/distribution at 4eede020: channels, the queue, the LinkedIn lane and statistics). Each section below is a row of capabilities.yml with status specified: its source is gone, its behaviour is here, and its platform target still owes it. The milestone that builds one sets the row done with a test as its proof and removes the section.

Reading the sections: Rails paths are relative to rails/ at d0a572fb, the last commit that has them (git show d0a572fb:rails/<path>). main means main at d0a572fb, before the merges; G4 and G5 mean code those branches brought in. Every platform test named was found by name when this was written; the tests under Build are to be written.

Row Platform target Where it gets built
rails.site-registry sites.registry G4's open items
rails.page-search content.list P4
rails.page-create content.create P4; the file side with G4's write-back
rails.writer sites.sync with rails.page-create
rails.assets-terms media.library G6; the terms with P4
rails.markdown-preview content.preview P4
rails.missing-previews media.generate G6
rails.access-guard platform.ops a test (G11)
rails.parity-tools content.import before the Jekyll fixtures are next re-recorded
rails.abc-wizard-ui books.abc G9
rails.abc-generator books.abc G9

Already absorbed, with their proofs in the ledger: rails.page-edit, rails.catalog, rails.front-matter, rails.doctor and workspace.doctor (G4); rails.distribution-queue, rails.channels, rails.linkedin and rails.linkedin-stats (G5); rails.events (main's contract tests: the outbox envelope and every event schema, app.user.interaction included).

rails.site-registry

Did (app/models/site.rb, app/controllers/admin/sites_controller.rb, app/dashboards/site_dashboard.rb, app/views/admin/sites/{index,show}.html.erb, app/services/site_sync.rb; tests test/integration/site_sync_test.rb, test/integration/admin_routes_test.rb)

  • Register a site by name and absolute path. The path is stored as its realpath, so two spellings of one root cannot both register ("has already been taken"). Refusals, each with its message: the path is not absolute ("must be an absolute path (in Docker, sites live under /sites)"); it is not a directory ("check the volume mount"); it is outside SITES_DIR when SITES_DIR is set ("must be inside SITES_DIR (…)"); it has no _config.yml ("is this a Jekyll site root?"). Creating a site syncs it at once. A sync failure keeps the registration and flashes "registered, but the sync failed: …".
  • SITES_DIR comes from the environment, or is /sites inside Docker. When it is unset, any absolute path may be registered.
  • Discover: lists the Jekyll roots (directories holding _config.yml) one or two levels under SITES_DIR that are not registered yet. Each is realpathed, deduplicated, kept only if it is strictly inside SITES_DIR, and sorted. The sites index shows them in a card ("N Jekyll roots with a _config.yml") with a Register and sync all button, which registers each under its basename and syncs it, then flashes "Registered a, b and c." or "No unregistered sites under …". When SITES_DIR is unset the card says "SITES_DIR is not set: register a site by its absolute path."
  • Sites list: name, path, page count, image count, last synced, sorted by name. Filters: unsynced: (never synced) and failing: (has a sync_error).
  • Site page shows path, source: subdir, collections_dir, page and image counts, last synced and the last sync error (as an alert, "Last sync failed: …").
  • Collections table: one row per collection with its page count and draft count. Drafts are draft: true or status: draft. Each collection links to the page list filtered site:<id> collection:<name>. With no rows it says "Not synced yet — press Sync" or "No content files".
  • _config.yml (read-only): the raw file through SitePath (no symlink at any component, a regular file, realpath inside the root). Reads at most 256 KiB as UTF-8, with invalid bytes scrubbed. When the file cannot be read it says "_config.yml is missing or not a regular file".
  • Buttons: Sync (flashes "Synced N pages, N images, N terms." or "Sync failed: …"), New page (in this site), Missing previews (the missing_preview: filter), Image generator ↗, Edit, Remove from index.
  • Remove from index: a Turbo confirm, then "Removed from the index. No file on disk was touched." Rows are deleted; files stay.
  • Edit: name and path can be changed. A changed path re-syncs.
  • Sync failures (an unsafe source/collections_dir, an OS error) record sync_error and last_synced_at on the site.

Platform today

  • G4 content/sites/{models,services,views,serializers}.py provide:
  • POST /api/v2/sites/: register a checkout inside the repository or SITES_DIR (realpath, _config.yml, readable YAML); its first sync starts as a job.
  • GET /api/v2/sites/discover/: workspace.yml's sites plus Jekyll roots one or two levels under SITES_DIR, less those registered.
  • GET/PATCH /api/v2/sites/<id>/: content source, renderer, theme tag, server, domains, deploy target. The overview counts pages as total, live and drafts.
  • Settings, findings, and the sync, export and doctor jobs.
  • G4 studio: web/packages/ui/src/sites/{SitesWorkspace,SiteView,JobLog}.tsx (registry, register one, overview, settings, findings, jobs).
  • Tests (G4): content/tests/sites/test_sites.py::test_registering_a_checkout_makes_the_site_and_syncs_it, ::test_a_checkout_must_be_a_jekyll_site_inside_the_repository_or_sites_dir, ::test_discover_lists_the_workspace_sites_not_yet_registered, ::test_the_list_carries_what_the_platform_manages, ::test_seeing_a_site_is_not_managing_it; web/packages/ui/test/sites.test.tsx ("lists every site with how it renders…", "registers a checkout the workspace declares and opens the new site").
  • Missing:
  • per-collection counts;
  • the read-only _config.yml (SiteRootPage.jekyll_config keeps only the keys the bridge reads, not the text);
  • register-all;
  • detach (remove from the registry, files untouched);
  • changing a site's checkout path or name;
  • showing source/collections_dir.
  • Untested: a positive test that a SITES_DIR root (not a workspace.yml site) is discovered, and a test that a second spelling of a registered checkout is refused.

Verdict: specified.

Build

  • API:
  • Add collections: [{collection, pages, drafts}] to GET /api/v2/sites/<id>/. Count BasePage descendants of each CollectionPage of the site; drafts are status draft. Add a (pages) row for pages under no collection.
  • Add source and collections_dir from SiteRootPage.jekyll_config.
  • GET /api/v2/sites/<id>/config/ returns {text, truncated}. Read _config.yml through sites.writer.confined_file (no symlink, regular file), at most 262,144 bytes, decoded as UTF-8 with replacement. A missing or refused file is a 404 envelope, "_config.yml is missing or not a regular file". Visible to whoever sees the site.
  • PATCH /api/v2/sites/<id>/ also takes checkout, re-validated by resolve_checkout and unique; a changed checkout starts a sync. It also takes name (the Wagtail Site.site_name).
  • DELETE /api/v2/sites/<id>/managed/ detaches the checkout: it deletes the ManagedSite row only. The Wagtail site, its pages and every file stay. Needs sites.manage_site; 409 while a job of the site is queued or running.
  • Studio (SiteView Overview, SitesWorkspace):
  • A "Collections" table with pages and drafts, each collection linking to Write's page list filtered site:<id> collection:<name> (see rails.page-search).
  • A collapsible read-only "_config.yml" code block.
  • Show source and collections dir.
  • A "Register all (N)" button over the discovered candidates, which registers each and lists every refusal with its message.
  • "Detach from its checkout" with a confirm dialog saying no file or page is touched.
  • Checkout and name editable in the registry form.
  • The list badges "never synced" and "last sync failed", the latter from the latest sync job's status. That replaces unsynced:/failing:.
  • Extension: by construction in G10 (the @zer0/ui Sites components render in the webview); no file-mode counterpart.
  • Tests (re-expressing site_sync_test.rb and admin_routes_test.rb):
  • content/tests/sites/test_sites.py::test_the_overview_counts_pages_and_drafts_per_collection: on the moved fixture content/tests/fixtures/jekyll-site, counts equal the catalog's by_collection.
  • ::test_the_config_is_shown_read_only_and_never_through_a_symlink: the text contains collections_dir: pages; a symlinked _config.yml gives 404.
  • ::test_discover_lists_unregistered_roots_under_sites_dir_only: copy a second fixture under SITES_DIR; it is listed, and a root outside is not.
  • ::test_a_checkout_registered_twice_by_another_spelling_is_refused: <parent>/./site.
  • ::test_changing_the_checkout_resyncs_and_detaching_touches_nothing.
  • web/packages/ui/test/sites.test.tsx: "shows each collection's pages and drafts and opens the filtered list", "registers every discovered site and lists the refusals".
  • Milestone: G4 (its open items: "per-collection counts and the read-only _config.yml view").

Did (app/dashboards/page_dashboard.rb COLLECTION_FILTERS, app/services/dashboard_search.rb, app/controllers/admin/{application,pages}_controller.rb, app/models/page.rb, app/fields/state_field.rb; tests test/integration/admin_routes_test.rb)

  • One search box. Whitespace-separated words of the form name: or name:value, where name is a known filter, narrow the list; every other word is free text. Administrate's parser cannot express a value with spaces, so a term with whitespace fell back to text search (Term#pages_search). An unknown name: is ignored.
  • Free text: case-insensitive substring (SQL LIKE %term%, lowercased with String#downcase) over title, description, author and source path, combined with OR.
  • Filters:
  • draft:: draft: true, a file in _drafts/, or front matter status: draft.
  • live:: not draft, published not false, date not in the future, and status ≠ draft.
  • future:: date later than the sync time.
  • error:: the front matter did not parse, or the file is not valid UTF-8. The file is still indexed, with its error.
  • collection:<name>, site:<id>, kind:<page|post|draft|document>, author:<name> (exact).
  • tag:<name> and category:<name>: exact element of the JSON list.
  • missing_preview:[site]: see rails.missing-previews.
  • Filters AND together and with the text.
  • Each row's state badge is one of error, draft, unpublished (published: false), future or live, in that precedence.
  • Columns: title, collection, kind, state, date, site.
  • Sort: date, newest first, undated last.
  • 50 per page by default; per_page up to 200.
  • A term's page links to "Pages with this tag/category/author": site:<id> tag:<name>, or text when the name has whitespace.
  • Edge: a search with no text and only filters matches everything (LIKE '%%').

Platform today

  • main content/api/pages.py PageFilter on GET /api/v2/content/pages/:
  • site, parent, type, status (draft, live, changed, scheduled, expired), q (title, draft title, slug), can_have_children;
  • ordering by title, latest_revision_created_at, last_published_at, path, nulls last;
  • 25 per page, at most 100.
  • Studio web/packages/ui/src/PageList.tsx: Status and Type selects, search box, tree walk.
  • Tests (main): content/tests/api/test_pages.py::test_the_page_list_spans_every_status_and_filters, ::test_a_page_without_a_revision_sorts_last_and_wagtails_placeholder_is_no_page; web/packages/ui/test/editor.test.tsx ("lists pages, walks into the tree, and filters by status through the platform").
  • MCP: content.search (read).
  • After G4's import the data is there:
  • collection: the parent CollectionPage.collection;
  • kind: ArticlePage for posts and dated documents, StandardPage otherwise, and BasePage.legacy_path holding _drafts/;
  • ArticlePage.tags, ArticlePage.categories (cms.Category) and ArticlePage.author.
  • Missing:
  • no collection, kind, tag, category, author, future or error filter;
  • q misses description, author and source path;
  • no sort by content date;
  • no typed filter language.
  • Unreadable files never become pages. They appear only as job log lines and the job result's errors count (G4 content/sites/services.py::run_sync).

Verdict: specified.

Build

  • API (api/pages.py PageFilter and PageSummarySerializer):
  • collection (name): descendants of the site's CollectionPage with that collection.
  • kind: page (no CollectionPage ancestor), post (collection posts, legacy_path not under _drafts/), draft (legacy_path under a _drafts/ directory), document (any other collection). Any other value is a 422 envelope naming the field.
  • tag: ArticlePage.tags__name__iexact; may repeat, and repeats AND together.
  • category: Category name or slug, case-insensitive; may repeat, AND.
  • author: exact ArticlePage.author or BookPage.author.
  • future=true: ArticlePage.date > now, any status.
  • live=true: maps to live (status live or changed).
  • site also accepts the managed site key.
  • q also searches search_description, ArticlePage.author and legacy_path.
  • ordering=date / -date: content date, nulls last. -date is what the filter language sorts by unless told otherwise.
  • Summary gains collection, date, site_id.
  • error: is not a page filter. Sync records each unreadable file as a finding with check: "sync", rule: "unreadable-file", file, and the reader's message as evidence. They are stored beside the doctor's findings on ManagedSite and replaced by each sync. GET /api/v2/sites/<id>/findings/?check=sync lists them.
  • The content.search tool takes the same filters (mcp surface).
  • Studio:
  • A pure parser parsePageQuery(text) in @zer0/ui (shared with the extension).
  • Tokens: whitespace splits except inside double quotes; key: or key:value (or key:"two words") with key in {draft, live, future, error, collection, site, kind, tag, category, author, missing_preview}. Anything else, unknown keys included, is free text joined into q. Repeated tag:/category: accumulate; other keys take the last value.
  • Parsed filters show as removable chips beside the existing selects and are kept in the URL.
  • The list adds Collection and Date columns.
  • error: (with a site) shows the site's "files that did not import" from the findings, linking to Sites → Findings.
  • Every tag, category and author shown on a page links to the list filtered by it, which replaces the Terms "Pages with this …" link.
  • Extension: by construction in G10. The file-mode page index (src/core/content/pageIndex.ts) keeps its own filters until then.
  • Owner decisions:
  • Rails counted status: draft (5 files: 3 in sites/irony-works, 2 in sites/zer0-pages) as a draft and excluded future-dated posts from live:. The importer (importers/jekyll.py::_is_draft) publishes both. Decide whether import maps status: draft → draft and a future date → scheduled (go_live_at = date), or whether future=true and a status front-matter view suffice.
  • Tests (re-expressing admin_routes_test.rb on content/tests/fixtures/jekyll-site, imported with import_site):
  • content/tests/api/test_pages.py::test_filters_narrow_the_list_to_exactly_the_matching_pages: draft, live, future, collection=docs, tag=fixture → exactly pages/_posts/2026-01-01-hello.md; plus kind, category and author; each against a queryset computed independently.
  • ::test_text_matches_title_description_author_and_source_path: outside-collections matches by path, Hello by title.
  • ::test_ordering_by_date_puts_undated_pages_last.
  • content/tests/sites/test_sites.py::test_unreadable_files_are_sync_findings: test_front_matter_errors_are_recorded_not_raised's file reaches findings?check=sync.
  • web/packages/ui/test/pagequery.test.ts: the parser table, including quoted values, unknown keys as text and repeated tags.
  • web/packages/ui/test/editor.test.tsx: "filters by a typed query and shows the filters as chips".
  • Milestone: P4 (content.list: "tag/category/author/errors filters to come"), built on G4's importer.

rails.page-create

Did (app/controllers/admin/pages_controller.rb new/create/duplicate/destroy, app/views/admin/pages/new.html.erb, app/services/page_editor.rb duplicate!/destroy!, app/models/site.rb#writable_collections, app/services/site_path.rb, lib/zer0_cms/cms/writer.rb; tests test/integration/page_editing_test.rb, test/zer0_cms/test_writer.rb)

  • New page: pick a site, then a form.
  • Collection: only declared collections whose directory exists and is not a symlink, excluding data; posts is selected by default.
  • Section: an existing subdirectory of that collection, at most 2 levels deep, each segment matching [A-Za-z0-9][A-Za-z0-9_-]*, no symlinks.
  • Title (required), slug (optional; derived from the title), description, author, tags (comma-separated), Draft (checked by default), and a body with live Markdown preview.
  • The file is YYYY-MM-DD-<slug>.md for posts (today's date) and <slug>.md otherwise. Front matter is title, date, then description, author, tags and draft: true when given, with YAML-rule quoting. A body that looks like front matter is kept as body. CRLF becomes LF, a leading newline is stripped, and a trailing newline is ensured.
  • Created with O_EXCL. An existing file or planted symlink is "already exists" or UnsafePath; never followed or overwritten. The path is re-synced, then the editor opens on the new page.
  • Refusals re-render the form (422) with the message: "unknown collection", "collection has no directory", "invalid section", "section does not exist", "invalid slug … use a-z, 0-9 and single hyphens".
  • A site with no writable collection says "declares no collection with a directory on disk".
  • Duplicate as draft: <stem>-copy.md beside the original, then -copy-2 … up to 1000.
  • Title " (copy)"; the title falls back to the file stem.</li> <li><code>draft: true</code> added; <code>permalink</code>, <code>redirect_from</code> and <code>preview</code> removed, so the copy cannot claim the URL, redirects or banner. Every other line is byte-identical (line surgery); the original is unchanged.</li> <li>A symlinked source, or one resolving outside the root, is refused.</li> <li>The edit form of the copy opens. When Jekyll would not read the copy as content it says "Duplicated; Jekyll does not read the copy as content."</li> <li><strong>Delete</strong>: a Turbo confirm. Refused (and the file kept) when the file changed since the last sync. The file is unlinked through <code>SitePath</code> (no symlink component, regular file, realpath inside) and the row removed. Flashes "Deleted <path>."</li> </ul> <p><strong>Platform today</strong></p> <ul> <li>Create (main):</li> <li><code>POST /api/v2/content/pages/</code> (parent, type, fields, body) makes one draft revision and publishes nothing. Tested by <code>content/tests/api/test_pages.py::test_creating_a_page_makes_one_draft_revision_and_publishes_nothing</code> and <code>::test_creatable_types_follow_the_tree_rules_and_permissions</code>.</li> <li>Studio <code>web/packages/ui/src/CreatePage.tsx</code> (parent, type, title, optional brief and drafter): <code>web/packages/ui/test/create.test.tsx</code> "creates a draft and starts no run once the brief’s topic is cleared".</li> <li>The file (G4): <code>exporters/jekyll.py::path_for</code> gives a new page in <code>_posts</code> <code><collections_dir>/_posts/YYYY-MM-DD-<slug>.md</code>, other collections <code><collections_dir>/_<c>/<slug>.md</code>, and the root <code><slug>.md</code>, with the slug transliterated by <code>sites.writer.slugify</code>. The write-back creates it O_EXCL, confined, and never over another page's file:</li> <li><code>content/tests/sites/test_sites.py::test_a_new_page_gets_a_file_and_the_job_says_so</code></li> <li><code>::test_a_new_page_never_takes_another_pages_file</code></li> <li><code>content/tests/sites/test_writer.py::test_a_new_file_is_created_once_and_never_through_a_planted_symlink</code></li> <li><code>::test_a_directory_symlinked_away_is_refused_and_nothing_lands_outside</code></li> <li><code>::test_only_plain_relative_paths</code></li> <li>Delete:</li> <li>There is no delete endpoint. <code>api/pages.py</code> only reports <code>perms.can_delete()</code> in the page detail.</li> <li>A page deleted in Wagtail loses its unchanged file at the next write-back; a file changed by hand stays: <code>content/tests/sites/test_sites.py::test_the_file_of_a_page_deleted_here_goes_unless_it_changed_by_hand</code> (G4).</li> <li>Duplicate: none. G4 lists it as open (content.create "duplicate to come").</li> <li>Gaps found:</li> <li>(a) No section: <code>path_for</code> always puts a new page at the collection root.</li> <li>(b) A declared collection with no files yet has no <code>CollectionPage</code> (<code>importers/jekyll.py::_container</code> makes one only when a file is imported), so nothing can be created in it.</li> <li>© Fixed: a page that is not live is written back with Jekyll's own <code>published: false</code> (Rails wrote <code>draft: true</code>) unless its file already holds itself back, so the next Jekyll build skips it — <code>content/tests/sites/test_sites.py::test_a_never_published_draft_written_back_is_marked_and_jekyll_skips_it</code>.</li> <li>(d) Slugs are transliterated silently at export. Rails refused an invalid slug, and a title like "!!!" with no usable slug, with a message.</li> </ul> <p><strong>Verdict:</strong> specified.</p> <p><strong>Build</strong></p> <ul> <li>API:</li> <li><strong>Duplicate</strong>: <code>POST /api/v2/content/pages/<id>/duplicate/</code> returns 201 with the copy's detail. Needs edit rights on the page and add-child rights on its parent; a lock is a 409.<ul> <li>The copy is a sibling, never live, with one draft revision (Wagtail <code>Page.copy(keep_live=False, copy_revisions=False)</code>).</li> <li>Title "<title> (copy)"; slug <code><slug>-copy</code>, then <code>-copy-2</code> … unique among siblings, giving up after 1000.</li> <li><code>front_matter</code> without <code>permalink</code>, <code>redirect_from</code>, <code>preview</code>; <code>preview_image</code> cleared. Date, author, tags, categories and body copied. No suggestions, no revisions.</li> <li>No <code>ImportedSource</code>. In a files site its file path is the original file's directory with <code><stem>-copy.md</code> / <code>-copy-N.md</code>, so a sectioned post's copy stays beside it.</li> </ul> </li> <li><strong>Delete</strong>: <code>DELETE /api/v2/content/pages/<id>/</code>. Needs <code>can_delete</code>. 409 when the page has children ("unpublish it, or delete its pages first") or is locked. The response names the file the next write-back will remove.</li> <li><strong>Create</strong> gains:<ul> <li><code>section</code> (files sites): segments matching the Rails regex, an existing non-symlinked directory under the collection's directory in the checkout, confined through <code>sites.writer</code>, kept on the page so <code>path_for</code> writes <code><collection dir>/<section>/<file></code>.</li> <li><code>GET /api/v2/sites/<id>/collections/</code> returns <code>{collection, sections[]}</code> for the create form.</li> <li>Registration and sync create a <code>CollectionPage</code> for every declared collection (not <code>data</code>) whose directory exists, so empty collections are creatable.</li> <li>Create returns a <code>file_path</code> preview, and refuses with 422 a slug whose file slug is empty ("!!!").</li> </ul> </li> <li><strong>Write-back</strong> (done, gap ©): a page that is not live carries <code>published: false</code> in its file unless the file already holds itself back (<code>sites.catalog.held_back</code>). This covers a new draft and a duplicate.</li> <li>Studio:</li> <li>"Duplicate as draft" in the page editor's header; it opens the copy.</li> <li>"Delete" with a confirm dialog naming the page and its file.</li> <li>CreatePage gains Section (when the parent is a collection of a files site), Slug with the resulting file path shown live, and Draft (the default).</li> <li>Extension: by construction in G10. File mode keeps <code>zer0Cms.draft.new</code>.</li> <li>Tests (re-expressing <code>page_editing_test.rb</code> and <code>test_writer.rb</code>):</li> <li><code>content/tests/api/test_pages.py::test_duplicate_is_a_draft_sibling_without_url_redirects_or_preview</code>: the second duplicate's slug ends <code>-copy-2</code>.</li> <li><code>::test_delete_needs_the_permission_and_refuses_a_page_with_children_or_a_lock</code>.</li> <li><code>::test_create_into_an_existing_section_and_refuse_a_missing_or_traversing_one</code>: <code>hacks</code> ok; <code>missing</code> and <code>../_docs</code> are 422.</li> <li><code>::test_an_empty_declared_collection_can_take_a_page</code>.</li> <li><code>content/tests/sites/test_sites.py::test_a_duplicate_writes_back_beside_its_original_as_a_draft</code>: on the moved fixture, <code>pages/_posts/2026-01-01-hello-copy.md</code> equals the original with <code>title: Hello (copy)</code>, no permalink, redirect_from or preview, and <code>published: false</code> before the closing fence; the original is byte-identical.</li> <li><code>::test_a_never_published_draft_written_back_is_marked_and_jekyll_skips_it</code> (done).</li> <li><code>web/packages/ui/test/editor.test.tsx</code>: "duplicates a page as a draft and opens the copy", "deletes a page after confirming".</li> <li><code>web/packages/ui/test/create.test.tsx</code>: "creates a page in a section and shows its file name".</li> <li>Milestone: P4 (content.create's "duplicate to come"). The section, empty-collection and draft-marker items ride with G4's write-back.</li> </ul> <h2 id="railswriter">rails.writer<a class="headerlink" href="#railswriter" title="Permanent link">¶</a></h2> <p><strong>Did</strong> (<code>lib/zer0_cms/cms/writer.rb</code>; <code>test/zer0_cms/test_writer.rb</code>)</p> <ul> <li>The only two ways the library made a new path, both confined.</li> <li><code>create(root, collection:, title:, slug:, section:, extras:, body:, date:)</code>:</li> <li>The collection is <code>posts</code>, or a declared collection other than <code>data</code>, whose directory exists and is not a symlink.</li> <li>The section must exist, with segments matching <code>[A-Za-z0-9][A-Za-z0-9_-]*</code>, confined to the collection's directory.</li> <li>Slug: a given slug is transliterated and lowercased. <code>LETTERS</code> maps ß/ẞ→ss, æ/Æ→ae, œ/Œ→oe, ø→o, đ/ð→d, þ→th, ł→l, ı→i, ħ→h, ŀ→l; NFD then strips combining marks. It must match <code>^[a-z0-9]+(-[a-z0-9]+)*$</code>, cut at the last hyphen at or before 60 characters (a single long word is cut hard).</li> <li>Posts are <code>YYYY-MM-DD-slug.md</code>.</li> <li><code>confine!</code>: the target, or its parent when the target is new, realpaths strictly inside the base.</li> <li>O_EXCL, mode 0644.</li> <li><code>duplicate(path, root:)</code>: see rails.page-create.</li> <li>Errors are <code>ArgumentError</code> (invalid input) or <code>UnsafePath</code> (escape).</li> </ul> <p><strong>Platform today</strong></p> <ul> <li>G4 <code>content/sites/writer.py</code> ports:</li> <li>confinement: plain relative paths, <code>lstat</code> at every component, realpath inside;</li> <li>O_EXCL create, with missing directories made one checked component at a time;</li> <li>the atomic replace re-checked before the rename;</li> <li><code>transliterate</code> / <code>slugify</code> / <code>slug_for</code> / <code>truncate</code>.</li> <li>Tests (G4): <code>content/tests/sites/test_writer.py::test_only_plain_relative_paths</code>, <code>::test_reads_a_regular_file_through_no_symlink</code>, <code>::test_a_new_file_is_created_once_and_never_through_a_planted_symlink</code>, <code>::test_a_directory_symlinked_away_is_refused_and_nothing_lands_outside</code>, <code>::test_missing_directories_are_made_one_checked_component_at_a_time</code>, <code>::test_a_replace_is_atomic_keeps_the_mode_and_needs_the_bytes_it_checked</code>, <code>::test_a_change_that_lands_mid_write_is_refused</code>, <code>::test_remove_only_what_is_still_expected</code>, <code>::test_slugs_are_validated_after_transliteration</code>, <code>::test_slugify_truncates_at_a_word_boundary</code>.</li> <li>The dated post file with a transliterated slug is proven by <code>content/tests/sites/test_sites.py::test_a_new_page_gets_a_file_and_the_job_says_so</code>.</li> <li>Not ported: duplicate, section placement, "collection must be declared with a directory", and the <code>Writer.create</code> front-matter shape. The exporter renders from scratch; YAML-rule quoting is proven by <code>content/tests/sites/test_frontmatter.py::test_dump_builds_a_block</code>.</li> <li>Note: G4 "missing directories are made" differs from Rails, which refused a missing section. Under the build below a person can only pick an existing section; only the platform's own <code>path_for</code> paths create directories.</li> </ul> <p><strong>Verdict:</strong> specified.</p> <p><strong>Build</strong></p> <ul> <li>The capability is the file half of rails.page-create's duplicate, section and empty-collection items. Build it there; nothing separate in the API or the studio.</li> <li>Tests at the file layer: <code>content/tests/sites/test_sites.py::test_a_duplicate_writes_back_beside_its_original_as_a_draft</code> (above) and <code>::test_a_page_in_a_section_writes_into_that_section</code>.</li> <li>The create from Rails' <code>test_create_quotes_titles_by_yaml_rules_and_keeps_a_body_that_looks_like_front_matter</code> should be re-expressed as <code>content/tests/importers/test_jekyll.py::test_a_new_page_with_a_yes_title_and_a_fenced_body_round_trips</code>: title <code>Yes</code>, body <code>---\nnot: front matter\n---\n</code>, export, then <code>sites.frontmatter.parse(strict=True)</code> gives title "Yes" and the body intact.</li> <li>Milestone: with rails.page-create (P4; the file side with G4).</li> </ul> <h2 id="railsassets-terms">rails.assets-terms<a class="headerlink" href="#railsassets-terms" title="Permanent link">¶</a></h2> <p><strong>Did</strong> (<code>app/models/{asset,term}.rb</code>, <code>app/dashboards/{asset,term}_dashboard.rb</code>, <code>app/controllers/admin/{assets,terms}_controller.rb</code>, <code>app/views/admin/terms/show.html.erb</code>, <code>app/controllers/files_controller.rb</code>, <code>app/fields/preview_image_field.rb</code>, <code>app/services/site_sync.rb#asset_row/#rebuild_terms</code>; tests <code>test/integration/files_test.rb</code>, <code>admin_routes_test.rb</code>)</p> <ul> <li><strong>Images</strong>: every <code>.png .jpg .jpeg .gif .webp .svg</code> file (case-insensitive) under the site source's <code>assets/</code> and <code>images/</code>, plus <code>preview_images.output_dir</code> when it is confined inside the root.</li> <li>Symlinked files and directories are skipped (<code>Catalog.media</code>).</li> <li>Indexed with path, extension, bytes and mtime.</li> <li>Read-only list, newest first, with a thumbnail column, filters <code>site:<id></code> and <code>ext:<ext></code>, and a show page.</li> <li><strong>Terms</strong>: per site, every tag, category and author with the number of pages carrying it (each page counted once per term), rebuilt on every sync.</li> <li>Read-only list sorted by count, with filters <code>tag:</code>, <code>category:</code>, <code>author:</code> and <code>site:<id></code>.</li> <li>A term's page links to "Pages with this tag/category/author".</li> <li><strong>Thumbnail server</strong> <code>GET /files/<absolute path></code>:</li> <li>Only the image extensions above (else 404 with an empty body).</li> <li>The site is chosen by string prefix of a registered realpath (no site gives 404).</li> <li>The rest is walked with <code>lstat</code>: any symlink file or directory gives 403, <code>..</code>/empty/<code>.</code> segments give 403, missing gives 404.</li> <li>The realpath must be inside the site.</li> <li>Served inline with <code>Content-Security-Policy: default-src 'none'; img-src 'self' data:; style-src 'unsafe-inline'; sandbox</code> (an SVG cannot run script in the app origin) and <code>X-Content-Type-Options: nosniff</code>.</li> <li>Every error is a bare status with no trace.</li> <li><strong>Preview thumbnails</strong> (<code>PreviewImageField.locate</code>): a page's <code>preview:</code> is looked up as <code><source>/<value></code>, then <code><source>/assets/<value></code> (the engine writes <code>/images/previews/x.png</code> for a file in <code>assets/images/previews/</code>, and the theme adds the prefix), then <code><root>/<value></code>.</li> <li>Query and fragment are stripped, and the value must have an image extension.</li> <li>External <code>http(s)</code> values are shown as text, "(external — not loaded)".</li> <li>A missing file reads "(no such image in the site)".</li> </ul> <p><strong>Platform today</strong></p> <ul> <li>main: Wagtail images (<code>cms.ContentImage</code>), the public <code>GET /api/v2/images/</code> (live content only; <code>api/urls.py</code> <code>PublicImages</code>), and renditions for thumbnails.</li> <li>The importer (<code>importers/jekyll.py::import_images</code>) imports only images a page's <code>preview</code>/<code>image</code> names, into collection "site: <key>", deduplicated by sha256.</li> <li>G4 ports <code>sites/catalog.py::media</code> (same dirs, symlinks skipped, output_dir confined): <code>content/tests/sites/test_catalog.py::test_media_ignores_an_output_dir_outside_the_root</code>, <code>::test_symlinked_entries_are_skipped_and_counted</code>. Nothing calls it.</li> <li>Tags are taggit on <code>ArticlePage</code>, categories the <code>cms.Category</code> snippet, author a string field. There is no API or studio view listing terms with counts.</li> <li>The studio has no media library (ledger media.library: studio missing).</li> <li>Bugs found (main and G4):</li> <li><code>import_images</code> tries only <code><source>/<value></code> and <code><root>/<value></code>, not <code><source>/assets/<value></code>. <code>sites/zer0-pages</code> (137 <code>preview: /images/previews/…</code> lines; files in <code>pages/assets/images/previews/</code>) and <code>sites/2005</code> (35 lines; files in <code>assets/images/previews/</code>) therefore import without their preview images.</li> <li><code>svg</code> is not in <code>WAGTAILIMAGES_EXTENSIONS</code> (unset, so Wagtail's default), while 2005's previews and the image engine's key-free <code>local</code> output are SVG.</li> <li><code>/media/</code> has no route in <code>config/urls.py</code>. Whatever serves it must also apply the SVG sandbox the Rails file server applied.</li> </ul> <p><strong>Verdict:</strong> specified.</p> <p><strong>Build</strong></p> <ul> <li>API:</li> <li>Sync imports every <code>sites.catalog.media(root)</code> image into the site's image collection, idempotent by sha256 and keeping the source path in a field or tag. Removing an image from the checkout does not delete it.</li> <li><code>GET /api/v2/media/images/?site=<id>&ext=&q=&ordering=-created_at</code> (people only, images of sites they see) returns title, file name, source path, size, dimensions, and a thumbnail rendition URL (<code>fill-160x100</code>).</li> <li><code>import_images</code> (and every preview lookup, see rails.missing-previews) uses the three candidates: source, source/assets, root.</li> <li><code>WAGTAILIMAGES_EXTENSIONS</code> adds <code>svg</code>. Every response that serves an original SVG or other media carries Rails' file CSP with <code>sandbox</code> and <code>nosniff</code>. Either a small media-serving view, or the documented web-server config with a test of the view used in development.</li> <li>Terms: <code>GET /api/v2/content/terms/?site=<id>&kind=tag|category|author</code> returns <code>[{kind, name, pages}]</code> sorted by pages, descending. Counts are distinct pages per site, from taggit, <code>Category</code> and <code>author</code>.</li> <li>Studio:</li> <li>A Media area (G6's "Media studio menu"): a grid of a site's images with thumbnail, path, type and size; filter by type; open an image to see its use (pages whose <code>preview_image</code> it is).</li> <li>Terms as a "Tags & authors" panel in Write: counts, each linking to the page list filtered by it.</li> <li>The page editor shows the preview image's thumbnail, or "(external — not loaded)" or "(no such image in the site)" for the front-matter value.</li> <li>Extension: by construction in G10. The file mode has <code>src/core/media</code>.</li> <li>Tests (re-expressing <code>files_test.rb</code> and <code>admin_routes_test.rb</code>):</li> <li><code>content/tests/importers/test_jekyll.py::test_a_preview_under_assets_is_found_like_the_engine_finds_it</code>: <code>preview: /images/previews/x.png</code> with the file in <code>assets/images/previews/</code> sets <code>preview_image</code>; an <code>https://</code> value sets nothing and keeps the key.</li> <li><code>content/tests/sites/test_sites.py::test_sync_imports_every_site_image_once</code>: catalog.media count equals the images in the collection; symlinked files and directories skipped; a second sync adds none.</li> <li><code>content/tests/media/test_library.py::test_the_library_lists_a_sites_images_with_thumbnails</code> and <code>::test_an_svg_is_served_sandboxed_and_nosniff</code>.</li> <li><code>content/tests/api/test_terms.py::test_terms_count_pages_per_site_and_kind</code>: the fixture tag <code>fixture</code> → 1.</li> <li><code>web/packages/ui/test/media.test.tsx</code>: "lists a site's images with thumbnails and filters by type".</li> <li>Milestone: G6 for images and thumbnails ("the Media studio menu"). The importer's <code>assets/</code> lookup is a bug fix for now (it is G4's importer). Terms ride with rails.page-search (P4).</li> </ul> <h2 id="railsmarkdown-preview">rails.markdown-preview<a class="headerlink" href="#railsmarkdown-preview" title="Permanent link">¶</a></h2> <p><strong>Did</strong> (<code>app/controllers/admin/markdown_previews_controller.rb</code>, <code>app/services/markdown_renderer.rb</code>, <code>app/javascript/controllers/markdown_preview_controller.js</code>, <code>app/fields/markdown_field.rb</code>, <code>app/views/fields/markdown_field/*</code>, the body field of <code>admin/pages/new.html.erb</code>; test <code>page_editing_test.rb</code> "the markdown preview returns sanitized HTML")</p> <ul> <li>Next to every body textarea (edit and new page) a preview pane re-renders 350 ms after typing stops.</li> <li>An in-flight request is aborted when a newer one starts.</li> <li><code>POST /admin/markdown_preview</code> with <code>markdown=</code> (CSRF token, same origin) answers with HTML.</li> <li>Server side:</li> <li>Input is cut to 1,000,000 characters.</li> <li>kramdown GFM (<code>hard_wrap: false</code>).</li> <li>Then an allow-list sanitizer. Tags: p br h1–h6 ul ol li pre code blockquote a img em strong del hr table thead tbody tr th td. Attributes: href src alt title class. No <code>on*</code>, no <code>javascript:</code> URLs, no other raw HTML.</li> <li>On a renderer error it logs a warning and returns the escaped source.</li> <li>The page show view renders the body the same way. The preview pane has <code>aria-live="polite"</code>.</li> </ul> <p><strong>Platform today</strong></p> <ul> <li>main <code>web/packages/ui/src/RichText.tsx</code>: TipTap with <code>@tiptap/markdown</code>. Rich mode is WYSIWYG, so formatting shows as it is typed.</li> <li>A block the editor cannot reproduce exactly (Liquid, raw HTML, constructs it would rewrite), or any block switched to Source, is a plain <code>Textarea</code> with no rendered view.</li> <li><code>PageEditor.tsx</code> links the platform's render of the latest saved revision (<code>preview_url</code>).</li> <li>Tests (main): <code>web/packages/ui/test/editor.test.tsx</code> (<code><BodyEditor></code> cases). No test covers a preview of source-mode Markdown.</li> <li>Python-Markdown 3.11 is pinned in <code>content/requirements.txt</code>. There is no HTML sanitizer dependency.</li> <li>Jekyll bodies with Liquid or raw HTML are the ones forced into source mode, and they are exactly the ones edited without any preview.</li> </ul> <p><strong>Verdict:</strong> specified.</p> <p><strong>Build</strong></p> <ul> <li>API: <code>POST /api/v2/content/preview/markdown/</code> with <code>{markdown}</code> returns <code>{html}</code>. People only, CSRF, throttled per person.</li> <li>Input cut to 1,000,000 characters.</li> <li>Python-Markdown with <code>tables</code>, <code>fenced_code</code> and <code>sane_lists</code>. Liquid tags (<code>{% … %}</code>, <code>{{ … }}</code>) are shown as literal text, not evaluated.</li> <li>Sanitized with <code>nh3</code> (a new pinned dependency; the reason is "an HTML sanitizer, not hand-rolled") using Rails' tag and attribute allow-lists and URL schemes http, https, mailto and relative.</li> <li>On a render error, the escaped source.</li> <li>Once P6's kramdown-compatible pipeline exists in <code>web/site/</code>, the studio may render client-side with it and this endpoint goes.</li> <li>Studio:</li> <li>In RichText's source mode, a split view with a "Preview" pane (<code>aria-live="polite"</code>) fed by the endpoint, 350 ms debounce, the previous request aborted.</li> <li>The same pane under CreatePage's body, if a body is added there (rails.page-create).</li> <li>Extension: by construction in G10. File mode has <code>zer0Cms.draft.preview</code>.</li> <li>Tests:</li> <li><code>content/tests/api/test_preview.py::test_markdown_preview_is_sanitized</code>: <code># Hi</code> gives <code><h1</code>; <code><script>alert(1)</script></code> and <code>[x](javascript:alert(1))</code> give neither <code><script</code> nor <code>javascript:</code>; an <code>onerror=</code> attribute is gone.</li> <li><code>::test_markdown_preview_cuts_huge_input_and_needs_a_person</code>.</li> <li><code>web/packages/ui/test/editor.test.tsx</code>: "previews a source-mode block after a pause and drops a stale response".</li> <li>Milestone: P4 (content.preview).</li> </ul> <h2 id="railsmissing-previews">rails.missing-previews<a class="headerlink" href="#railsmissing-previews" title="Permanent link">¶</a></h2> <p><strong>Did</strong> (<code>app/services/image_engine.rb</code>, <code>PagesController#generate_preview</code>/<code>#index</code>, <code>PageDashboard</code> <code>missing_preview:</code>, <code>views/admin/pages/show.html.erb</code>, <code>views/admin/sites/show.html.erb</code>, <code>PageEditor#replace_engine_write!</code>; tests <code>test/integration/image_engine_test.rb</code>, <code>test/services/image_engine_settings_test.rb</code>)</p> <ul> <li><strong>Settings</strong> come from the site's <code>_config.yml</code> <code>preview_images:</code> block.</li> <li><code>front_matter_key</code>: default <code>preview</code>. It must match <code>^[A-Za-z_][A-Za-z0-9_-]*$</code>, else the error "is not a plain key".</li> <li><code>output_dir</code>: default <code>assets/images/previews</code>, trailing slash trimmed. It must resolve inside the site source through <code>Catalog.confine</code>. Absolute values, <code>..</code> and a symlink out are all refused with "resolves outside the site root". It must not be the source itself ("must be a directory below the site source").</li> <li><strong>Missing list</strong>: the image engine walks every collection directory for <code>*.md</code> with front matter (the Python engine's <code>--list-missing --collection all --provider local</code>).</li> <li>A file is missing a preview when the key is absent or empty, or when its value is not <code>http(s)://</code> and no file exists at <code><source>/<value></code> or <code><source>/assets/<value></code>.</li> <li>The output gives the root-relative path, title, and "Current preview (not found)"; ANSI colour is stripped and paths outside the root dropped.</li> <li>The <code>missing_preview:</code> filter (or <code>missing_preview:<site id></code>) narrows the page list to indexed pages among them. A file the engine walks but Jekyll does not read, such as <code>_posts/undated.md</code>, has no row.</li> <li>When the engine cannot run, the list renders without the filter, flashing "missing_preview: is unavailable — <reason>".</li> <li>The site page links to "Missing previews".</li> <li><strong>Generate preview (local)</strong>, per page, one generation at a time per process (mutex):</li> <li>Refused before the engine runs when the file changed since the last sync, or when the settings are refused.</li> <li>The engine (free <code>local</code> provider, no credentials) writes the image into <code>output_dir</code> and the key into the file.</li> <li>The engine's write is accepted only if it changed nothing but that key, to a string value. The key is then re-applied to the original bytes by line surgery (appended before the closing fence), written atomically, and re-synced. Otherwise the original bytes are restored and "the image engine changed more than <key>: …; its edit was undone" is shown.</li> <li>The site is re-synced so the new image is indexed.</li> <li>Outcomes: "Generated a local preview: <key>: <value>"; "<path> already has a preview (<value>); the engine drew nothing."; "The engine drew nothing for <path>."; "The image engine failed: <last 6 log lines, ≤600 chars>".</li> <li>The button is disabled, with the reason as its title, when the engine is unavailable: no gem, or no python3 with PyYAML.</li> <li><strong>Backends</strong>:</li> <li>Facade: <code>Zer0ImageGenerator::Facade.missing_previews</code>/<code>generate_one</code>.</li> <li>Python subprocess: the engine run in the site root with <code>--file F --provider local --output-dir D --front-matter-key K --rasterizer auto|$ZER0_CMS_RASTERIZER --parallel 2</code>. Only PATH, HOME, LANG, LC_ALL and TMPDIR are passed (no credential reaches it), plus <code>PYTHONDONTWRITEBYTECODE</code>/<code>PYTHONIOENCODING</code>. It runs in its own process group with a 300 s deadline that kills the group.</li> <li>Without a rasterizer the local provider keeps an SVG, so <code>.svg</code> or <code>.png</code>.</li> <li>Bigger runs link out to <code>ZER0_IMAGE_GENERATOR_URL</code>: only an <code>http(s)</code> URL is used, default <code>http://localhost:3000</code>.</li> </ul> <p><strong>Platform today</strong></p> <ul> <li>Nothing on main, G4 or G5. Ledger media.generate is missing on every surface.</li> <li>G4's doctor reads <code>preview_images:</code> only to warn ("no-preview-images-config"): <code>content/tests/sites/test_doctor.py::test_image_engine_check</code>.</li> <li>The engine itself survives the deletion: <code>packages/zer0-image-generator/lib/zer0_image_generator/preview_generator.py</code> (<code>check_preview_exists</code>, <code>--list-missing</code>, <code>--file</code>, the local provider) stays until G6. Deleting <code>rails/</code> removes only the UI, the bridge and the write-back guard.</li> <li>The platform's <code>BasePage.preview_image</code> is the page's preview. The importer's lookup bug (rails.assets-terms) would make zer0-pages and 2005 pages look missing.</li> </ul> <p><strong>Verdict:</strong> specified.</p> <p><strong>Build</strong> (inside G6's <code>content/media/</code> rewrite)</p> <ul> <li>API:</li> <li>Preview settings per site: key, output dir and provider defaults. Read from <code>_config.yml</code> <code>preview_images:</code> at sync and editable through G6's "<code>preview_images:</code> site-config editor". Rails' key regex and output_dir confinement are enforced at save and at sync, with Rails' messages.</li> <li><code>missing_preview=true</code> on <code>GET /api/v2/content/pages/</code> (with <code>site</code>): pages of a site whose <code>preview_image</code> is null and whose front-matter key value is absent or empty, or is a local path that does not resolve through the three-candidate lookup. An external <code>http(s)</code> value counts as present.</li> <li><code>GET /api/v2/sites/<id>/</code> gains <code>missing_previews: <count></code>.</li> <li><code>POST /api/v2/content/pages/<id>/preview/</code> with <code>{provider: "local"|…, force?: bool}</code> returns 202 with an <code>ImageRun</code> job (G6), exclusive per site.<ul> <li>The provider draws <code><slug-of-title>.<svg|png></code> into the site's image collection, with source path <code><output_dir>/<file></code>.</li> <li>The result is a suggestion on the page's preview (proposed <code>preview_image</code> plus the front-matter key <code>/<output_dir minus its leading assets/>/<file></code>), accepted by a person in Review. Outcomes <code>generated</code>, <code>skipped</code> ("already has a preview (<value>)" unless <code>force</code>), <code>nothing drawn</code> and <code>failed</code> (log tail) are on the job.</li> <li>On write-back the key lands by line surgery before the closing fence, and the image file is written into the checkout with the confined writer.</li> <li>Paid providers take credentials only from G6's <code>ProviderCredential</code>; the local provider needs none.</li> <li>Unavailable providers are listed with their reason (<code>GET /api/v2/media/providers/</code>).</li> </ul> </li> <li>Studio:</li> <li>Site Overview: "Missing previews (N)", which opens Write's list with <code>missing_preview:</code> and the site.</li> <li>Page editor: "Generate preview" with a provider select (local first), disabled with the provider's reason when unavailable. It follows the job's log and shows the proposed image in the suggestion panel.</li> <li>Batch runs, dry run and list-missing for a whole site live in G6's Media area. That replaces the "Image generator ↗" link-out.</li> <li>Extension: by construction in G10 (the page editor's button). File mode keeps its own media commands.</li> <li>Tests (re-expressing <code>image_engine_test.rb</code> and <code>image_engine_settings_test.rb</code> on <code>content/tests/fixtures/jekyll-site</code>):</li> <li><code>content/tests/media/test_missing.py::test_the_missing_list_matches_the_engine_on_the_fixture</code>: the engine walk gives <code>pages/_posts/2026-01-01-hello.md</code>, <code>2099-01-01-future.md</code>, <code>sub/2026-03-03-nested.md</code> and <code>undated.md</code>; the page filter gives those minus <code>undated.md</code>; two registered copies of the site give twice as many without <code>site</code>.</li> <li><code>::test_settings_defaults_and_the_sites_block</code>: <code>preview</code>, <code>assets/images/previews</code>; <code>image</code>, <code>img/og/</code> → <code>img/og</code>.</li> <li><code>::test_an_output_dir_or_key_that_could_escape_is_refused</code>: <code>../outside</code>, <code>/img/og</code>, <code>.</code>, a symlink out, and the key <code>"a: b"</code>, each with Rails' message and before any provider runs.</li> <li><code>::test_a_local_preview_is_proposed_and_writes_back_as_one_line</code>: accepting it then writing back differs from the original only by <code>preview: /images/previews/hello.(svg|png)</code> after <code>tags: [fixture]</code>; the image exists under <code>assets/images/previews/</code>; the page is no longer missing.</li> <li><code>::test_a_second_generation_says_it_already_has_a_preview_and_changes_nothing</code>.</li> <li><code>::test_an_unavailable_provider_is_refused_with_its_reason</code>.</li> <li><code>web/packages/ui/test/media.test.tsx</code>: "generates a preview, follows the job and shows the proposed image", "disables generation with the provider's reason".</li> <li>Milestone: G6.</li> </ul> <h2 id="railsaccess-guard">rails.access-guard<a class="headerlink" href="#railsaccess-guard" title="Permanent link">¶</a></h2> <p><strong>Did</strong> (<code>app/controllers/concerns/access_guard.rb</code>, <code>app/services/local_network.rb</code>, <code>config/application.rb</code> (hosts), <code>config/initializers/content_security_policy.rb</code>, <code>config/initializers/filter_parameter_logging.rb</code>, <code>docker-compose.yml</code> <code>cms</code>; tests <code>test/integration/security_test.rb</code>, <code>test/services/local_network_test.rb</code>)</p> <ul> <li>Without <code>ZER0_CMS_PASSWORD</code>, every request is refused unless it comes from this machine: a plain-text 403, "zer0-CMS answers requests from this machine only. Set ZER0_CMS_PASSWORD to allow other clients."</li> <li>Local means the TCP peer (<code>REMOTE_ADDR</code>, never <code>remote_ip</code>) and every <code>X-Forwarded-For</code> hop are loopback (127/8, ::1, <code>[::1]</code>, ::ffff:127.x).</li> <li>With <code>ZER0_CMS_TRUST_DOCKER_GATEWAY=1</code>, set by compose, the container's default gateway (from <code>/proc/net/route</code>) also counts.</li> <li>With <code>ZER0_CMS_PASSWORD</code>, every surface needs HTTP basic auth (realm "zer0-CMS"), compared in constant time. The user is <code>ZER0_CMS_USER</code>, default <code>zer0</code>; an empty value means the default.</li> <li>Host allow-list: <code>localhost</code>, <code>127.0.0.1</code>, <code>::1</code> and <code>[::1]</code>, plus a comma-separated <code>ZER0_CMS_HOSTS</code>. Any other Host gets a 403 (DNS-rebinding guard).</li> <li>CSP:</li> <li><code>default-src 'self'; base-uri 'self'; connect-src 'self'; font-src 'self' data:; form-action 'self'; frame-ancestors 'none'; img-src 'self' data:; object-src 'none'; script-src 'self'; style-src 'self'</code>.</li> <li>A fresh base64 nonce per request on <code>script-src</code>/<code>style-src</code>, carried by the importmap and module scripts and a <code>csp-nonce</code> meta tag.</li> <li>No <code>unsafe-inline</code> or <code>unsafe-eval</code>. Administrate's compiled JS and CSS are not loaded. Flashes are escaped.</li> <li>CSRF on every write.</li> <li>Logs filter <code>passw email secret token _key crypt salt certificate otp code state</code>.</li> <li>Compose publishes on 127.0.0.1 only.</li> </ul> <p><strong>Platform today</strong></p> <ul> <li>Sign-in for every studio and API endpoint, and no agents on people's endpoints (main): <code>content/tests/api/test_pages.py::test_the_studio_endpoints_are_for_signed_in_people_not_agents</code>.</li> <li>CSRF and edit rights: <code>::test_saving_needs_the_csrf_token_and_edit_rights</code>.</li> <li>Enforced studio CSP with a per-request nonce, <code>script-src 'self'</code>, no <code>unsafe-inline</code>, <code>frame-ancestors 'none'</code>, <code>object-src 'none'</code>, <code>base-uri</code>/<code>form-action 'self'</code>: <code>content/tests/api/test_studio.py::test_every_studio_path_is_the_index_with_a_fresh_nonce</code>.</li> <li>Security headers: <code>content/tests/ops/test_security_headers.py::test_html_responses_carry_the_security_headers</code>.</li> <li>Redacted JSON logs: <code>content/tests/ops/test_logging.py::test_tokens_are_redacted</code>.</li> <li><code>ALLOWED_HOSTS</code> defaults to <code>localhost</code>, <code>127.0.0.1</code> and <code>.localhost</code> from the environment (<code>content/config/settings/base.py</code>), with no test.</li> <li>Compose publishes the platform on <code>127.0.0.1:${CONTENT_PORT:-8000}</code>.</li> <li>The Wagtail admin's CSP is report-only. ADR 0006 puts no product screens there.</li> </ul> <p><strong>Verdict:</strong> specified (test-only). The loopback-or-password and Docker-gateway mechanics are replaced by the platform's sign-in (G3 adds accounts); that half is <code>dropped</code> once the owner agrees.</p> <p><strong>Build</strong></p> <ul> <li>API/ops: nothing new in code.</li> <li>Map <code>ZER0_CMS_HOSTS</code> → <code>ALLOWED_HOSTS</code> (and <code>CSRF_TRUSTED_ORIGINS</code>) in <code>content/README.md</code>'s settings table.</li> <li>State in <code>content/ops/README.md</code> that no endpoint but the public Wagtail read API, probes and newsletter pages answers anonymously, so a platform reachable beyond loopback relies on sign-in, not on the peer address.</li> <li>Studio: none. Extension: none.</li> <li>Tests:</li> <li><code>content/tests/ops/test_hosts.py::test_an_unknown_host_is_refused</code>: <code>HTTP_HOST=attacker.example</code> gives 400 (DisallowedHost) with the error envelope and no body content.</li> <li><code>::test_hosts_named_in_the_environment_are_accepted</code>.</li> <li><code>content/tests/api/test_pages.py::test_a_forwarded_for_header_grants_nothing</code>: <code>X-Forwarded-For: 127.0.0.1</code> without a session is still 401.</li> <li>Milestone: G11 (the retirement commit for <code>rails/</code>); the accounts half is G3.</li> </ul> <h2 id="railsparity-tools">rails.parity-tools<a class="headerlink" href="#railsparity-tools" title="Permanent link">¶</a></h2> <p><strong>Did</strong> (<code>bin/jekyll-parity</code>, <code>bin/front-matter-roundtrip</code>; outputs <code>test/fixtures/*.expected.json</code>)</p> <ul> <li><code>jekyll-parity SITE [--json]</code> needs the <code>jekyll</code> gem 4.4.x. It runs Jekyll's reader from the site root the way <code>jekyll build</code> would:</li> <li>safe mode, <code>plugins: []</code>, <code>future</code>/<code>unpublished</code>/<code>show_drafts</code> true, no incremental, no disk cache;</li> <li>when the theme gem is absent, a note and no theme config;</li> <li><code>reader.read_directories</code> + <code>read_included_excludes</code> + <code>CollectionReader</code>, with no render or write.</li> <li>It lists <code>[collection|"pages", source-relative path]</code> for every content-extension page or document, sorted and unique, and counts <code>non_content_pages</code>, <code>non_content_posts</code> and <code>non_content_documents</code>.</li> <li>It diffs these against <code>Catalog.scan</code>: only in Jekyll, only in the catalog, count mismatches, symlinks skipped. Exit 0 when equal, 1 on any difference or a refused site, 2 on usage or a missing gem.</li> <li><code>--json</code> prints Jekyll's lists, with <code>generator</code> "Jekyll <v> reader via rails/bin/jekyll-parity" and <code>notes</code>. That output is the committed oracle the catalog tests compare against.</li> <li><code>front-matter-roundtrip SITE…</code> is read-only. For every catalogued file with a parseable block it checks:</li> <li>noop: <code>update_keys(text, parsed data)</code> is byte-identical;</li> <li>re-emit per key: set a sentinel, set it back, the data reads back equal, and deleting the key from either text gives the same bytes.</li> <li>It prints per-site counts (<code>noop_ok/fail</code>, <code>keys</code>, <code>reemit_ok/fail</code>, <code>no_front_matter</code>, <code>unparseable</code>, <code>skipped_encoding</code>) and the first 25 failures. Exit 1 on any failure.</li> </ul> <p><strong>Platform today</strong> (G4)</p> <ul> <li>The oracle files moved to <code>content/tests/fixtures/jekyll-site{,-src}.expected.json</code> with their fixture sites.</li> <li><code>content/tests/sites/test_catalog.py::test_the_fixture_sites_match_jekylls_reader_byte_for_byte</code> renders the Python walk in <code>--json</code> shape and compares bytes.</li> <li>The round-trip property holds over the five front-matter fixtures (<code>content/tests/fixtures/front_matter/*.md</code>): <code>content/tests/sites/test_frontmatter.py::test_every_fixture_round_trips</code>.</li> <li>Import → export byte equality over real sites: <code>content/tests/importers/test_jekyll.py::test_the_real_sites_round_trip_byte_for_byte</code> (G4; zer0-pages slow). Unchanged pages are written verbatim, so it does not exercise surgery on those sites.</li> <li>Missing:</li> <li>a way to re-record Jekyll's lists when a fixture changes (Ruby with the gem; the ledger note says so);</li> <li>the surgery's re-emit property over whole real sites.</li> </ul> <p><strong>Verdict:</strong> specified.</p> <p><strong>Build</strong></p> <ul> <li>Ops (no Ruby in the repository): <code>tools/jekyll_parity.py --site PATH [--json]</code>, beside P1's <code>tools/site_manifest.py</code>.</li> <li>It copies the fixture to a temporary directory and adds one Liquid page that prints, as JSON, the <code>relative_path</code> of every <code>site.pages</code> item and every document of every <code>site.collections</code> (posts and drafts included).</li> <li>It builds that copy with the pinned Jekyll 4 image P2 uses (<code>tools/jekyll/Dockerfile</code>): <code>--safe --future --unpublished --drafts</code>, plugins none, the theme option off.</li> <li>Python applies the catalog's content-extension rule, counts the rest, and writes the expected-JSON shape (<code>generator</code> "Jekyll <v> reader via tools/jekyll_parity.py"). It diffs against <code>sites.catalog.scan</code> with the same exit codes, 0, 1 and 2 (2 when docker or the image is unavailable).</li> <li>Owner decision if the Liquid route cannot reproduce the reader-level counts: freeze the two oracles, and re-record them out of tree.</li> <li><code>python -m sites.frontmatter --roundtrip PATH…</code> (stdlib + PyYAML, like <code>python -m sites.doctor</code>) implements both properties with the same counters, the first 25 failures and the same exit codes.</li> <li>Studio and Extension: none; these are proof tools.</li> <li>Tests:</li> <li><code>content/tests/sites/test_frontmatter.py::test_every_in_repo_site_round_trips</code> (marked <code>slow</code>): runs the round trip over <code>sites/*</code> checkouts and asserts zero failures.</li> <li><code>tools/tests/test_jekyll_parity.py::test_the_recorder_reproduces_the_committed_lists</code>: skips with a reason without docker, and asserts byte equality with <code>content/tests/fixtures/jekyll-site{,-src}.expected.json</code>.</li> <li>Milestone: G11 (a prerequisite of deleting <code>rails/bin/jekyll-parity</code>). The recorder sits with P1/P2's Jekyll tooling.</li> </ul> <p><strong>Keep:</strong> <code>content/tests/fixtures/jekyll-site/</code>, <code>jekyll-site-src/</code>, both <code>.expected.json</code> files and <code>front_matter/*.md</code> (with <code>zer0-mistakes-post.md</code> renamed <code>theme-docs-post.md</code>). G4 already moved all of these from <code>rails/test/fixtures/</code>. Nothing else under <code>rails/</code> is a fixture worth keeping for these rows; the inline expectations (for example <code>image_engine_test.rb</code>'s <code>MISSING</code> list) are copied into the specs above.</p> <h2 id="the-abc-engine">The ABC engine<a class="headerlink" href="#the-abc-engine" title="Permanent link">¶</a></h2> <p>Read at <code>d0a572fb</code> (<code>git show d0a572fb:<path></code>). The ABC wizard (web) and the ABC generator (library + CLI) are one engine with two front ends: <code>AbcBooksController</code> and <code>bin/zer0-cms</code> both drive <code>Zer0Cms::Abc::Wizard</code> + <code>JekyllExporter</code>, so the generator section holds the algorithm and the wizard section holds the person's flow. Determinism check, run for this spec: main's <code>rails/lib</code> (extracted to a scratch directory, Ruby 2.6 with a <code>YAML.safe_load_file</code> shim) regenerates <code>sites/drsai/_data/abc_books/it-alphabet.json</code> and <code>sites/drsai/pages/_books/it-alphabet/index.md</code> <strong>byte for byte</strong> (<code>cmp</code> clean) from <code>theme "IT systems", slug it-alphabet, art_style isometric-tech-toy, provider deterministic</code>, so drsai's committed book is the Rails golden output.</p> <h2 id="railsabc-wizard-ui">rails.abc-wizard-ui<a class="headerlink" href="#railsabc-wizard-ui" title="Permanent link">¶</a></h2> <p><strong>Did</strong></p> <ul> <li>Routes (<code>rails/config/routes.rb</code>): <code>GET /abc/new</code> (form), <code>POST /abc/preview</code>, <code>POST /abc/export</code>, <code>GET /abc/catalog.json</code>; a sidebar entry "ABC books" (<code>rails/app/views/layouts/_zer0_sidebar.html.erb</code>); behind the app's generic access guard (loopback or password, <code>rails/test/integration/security_test.rb</code>).</li> <li>Form (<code>rails/app/views/abc_books/new.html.erb</code>): theme (text, default "IT systems", datalist of bundled themes with <code>_</code> shown as spaces; hint: "Bundled themes generate offline; any other theme uses Claude (needs <code>ANTHROPIC_API_KEY</code> or <code>CLAUDE_CODE_OAUTH_TOKEN</code>)"), art style (select of catalog style names), palette (select with "(style default)" = blank), background, mood (selects from the catalog), slug (placeholder "auto from the title"), audience (Toddler <code>toddler</code> / Preschool <code>preschool</code> / Early reader <code>early-reader</code>), export target (text, prefilled from <code>DRSAI_SITE_ROOT</code>, datalist of registered <code>Site</code> paths; hint: export writes <code>pages/_books/<slug>/index.md</code> and <code>_data/abc_books/<slug>.json</code>, preview writes nothing). Two buttons: "Preview book" (posts to preview) and "Export" (<code>formaction</code> export). The controller also permits <code>title</code>, <code>subtitle</code> and <code>provider</code> (not on the form); blanks are dropped, <code>theme</code> is stripped, <code>provider</code> defaults <code>auto</code>, <code>background</code> <code>plain</code>, <code>mood</code> <code>playful</code> (<code>rails/app/controllers/abc_books_controller.rb#wizard_params</code>).</li> <li>Preview: runs the wizard, renders the book Markdown with the exporter's <code>render_markdown</code> (no file written), shows "Preview — <title>", "<subtitle> · <N> letters · art style <code><id></code> · nothing was written", the Markdown in a <code><pre></code>, and a note pointing back to Export (<code>preview.html.erb</code>).</li> <li>Export: resolves the target (<code>rails/app/services/abc_export_target.rb</code>), runs the wizard, writes the bundle, shows both written paths, "<N> illustration(s) still to render" and the next commands <code>python3 tools/generate_illustrations.py --book <slug> --dry-run</code> then without <code>--dry-run</code> (<code>export.html.erb</code>).</li> <li>Target rules (<code>AbcExportTarget.resolve!</code>), each a <code>Refused</code> with this message: blank → "Choose the target site directory (a Jekyll root with _config.yml) to export into."; not absolute → "The export target must be an absolute path."; not a directory → "<path> is not a directory."; realpath has no regular, non-symlink <code>_config.yml</code> → "<path> has no _config.yml, so it is not a Jekyll site root."; with <code>SITES_DIR</code> set, not strictly inside it (the mount itself refused) → "<path> is not a site inside SITES_DIR (<dir>)."; any <code>SystemCallError</code> → "The export target cannot be used: <msg>".</li> <li>Errors: <code>Spec::InvalidSpec</code>, <code>ArgumentError</code> (bad provider name, incomplete plan) and <code>Anthropic::ProviderError</code> (and <code>Refused</code> on export) redirect to <code>/abc/new</code> with the message as a flash alert, status 303. Quirks: <code>Lexicon::UnknownTheme</code> (provider <code>deterministic</code> with an unbundled theme) is not rescued (a 500); the wizard's warnings (style fallback, auto→Claude) are never shown on the web.</li> <li>Catalog: <code>GET /abc/catalog.json</code> = <code>ArtStyles#to_menu</code> plus <code>"themes": [<lexicon slugs>]</code> (shape in the generator section).</li> <li>Tests (<code>rails/test/integration/abc_books_test.rb</code>): the form renders in the admin layout with an <code>input[name=target]</code>; preview renders <code>layout: book-abc</code> and writes nothing; export refuses a missing target, a directory without <code>_config.yml</code> (and leaves it empty), the <code>SITES_DIR</code> mount itself (no <code>pages/</code> created); export into a real Jekyll root writes <code>pages/_books/it-test-book/index.md</code> and <code>_data/abc_books/it-test-book.json</code>; the catalog is JSON with a <code>themes</code> key.</li> </ul> <p><strong>Platform today</strong></p> <ul> <li>No ABC endpoint, no catalog, no preview, no export action. The only way to generate is a drafter run: <code>POST /api/v2/agent-runs/ {agent: "drafter", page_id, input: {theme}}</code> (<code>content/api/views.py::_create_run</code> passes <code>input</code>), which on a <code>BookPage</code> with <code>profile="abc"</code> selects <code>agents.handlers.abc.draft</code> (<code>content/agents/runner.py::apply_profile</code>, <code>content/agents/definitions/drafter.yaml</code>).</li> <li>Studio: <code>web/packages/ui/src/CreatePage.tsx</code> makes a page of any type its parent allows (a <code>BookPage</code> under a <code>books</code> collection) and can start the drafter, but only with a brief topic and with no <code>input</code>, so the abc handler takes the theme from the page title (works only when the title is a bundled theme, e.g. "IT systems"). <code>web/packages/ui/src/BodyEditor.tsx</code> edits <code>letter</code> blocks as structured fields. The Books area (<code>web/packages/ui/src/books/</code>) holds the library's books only: a Jekyll site's ABC book is a 404 there (<code>content/tests/books/test_api.py::test_a_jekyll_sites_books_are_not_the_librarys</code>). No art-style, palette, background, mood, audience or slug choice anywhere; no extension counterpart.</li> <li>G4 (<code>overhaul/sites-jobs</code>, merged with this change) adds <code>ManagedSite</code> (a registered checkout inside the repository or <code>SITES_DIR</code>), the write-back job over <code>exporters.jekyll.site_files</code> with the confined writer and stale-write guard — the platform's replacement for <code>AbcExportTarget</code>. It adds nothing ABC-specific.</li> <li>Proofs that exist (all partial for this row): <code>content/tests/agents/test_drafter.py::test_the_abc_profile_writes_every_missing_letter_from_the_lexicon</code>, <code>content/tests/agents/test_drafter.py::test_at_policy_draft_the_abc_drafter_writes_the_revision_itself</code>, <code>content/tests/books/test_api.py::test_a_jekyll_sites_books_are_not_the_librarys</code>.</li> </ul> <p><strong>Verdict</strong> — <code>specified</code>: a person cannot choose a style, preview a book or export it from the studio; <code>books.abc</code> is <code>api: missing, studio: missing</code>.</p> <p><strong>Build</strong></p> <ul> <li>API (<code>content/books/urls.py</code>, <code>views.py</code>, <code>serializers.py</code>, in the committed OpenAPI document; thin over the engine in <code>content/books/abc.py</code>, see the generator row):</li> <li><code>GET /api/v2/books/abc/catalog/</code> → <code>{version, styles: [{id, name, summary, default_palette, default_lettering, best_for}], palettes, backgrounds, lettering, moods: [{id, name}], themes: [{slug, theme, title}], audiences: [toddler, preschool, early-reader]}</code>.</li> <li><code>POST /api/v2/books/abc/preview/</code> with <code>{theme, title?, subtitle?, slug?, art_style?, palette?, background?, mood?, lettering?, audience?, provider: auto|lexicon|model}</code> → bundled theme: <code>200 {spec, markdown, sidecar, warnings, planned_images}</code>, synchronous and deterministic; otherwise a drafter run (<code>202 {run}</code>, <code>Idempotency-Key</code> honoured) whose output carries the same body. Writes nothing. Invalid spec → <code>400</code> with the Rails messages; <code>provider: lexicon</code> with an unbundled theme → <code>400</code> (not the Rails 500); an unknown style → <code>200</code> with the fallback warning.</li> <li><code>POST /api/v2/books/abc/</code> → creates the book as a draft <code>BookPage</code> (<code>profile="abc"</code>, <code>series="abc-language"</code>) under the chosen site's <code>books</code> collection, the spec's knobs on the page and one <code>letter</code> block per letter; <code>201</code> with the page; refused without add permission on that collection.</li> <li><code>POST /api/v2/books/abc/<id>/export/</code> → starts the site's write-back job (G4) for that book's two files (<code><collections_dir>/_books/<slug>/index.md</code>, <code>_data/abc_books/<slug>.json</code>); <code>202 {job}</code>; a site without a registered checkout is refused; a hand-edited file is a job conflict, never overwritten. No free filesystem path is accepted (the registry replaces <code>AbcExportTarget</code>).</li> <li>List a site's ABC books (<code>GET /api/v2/books/abc/?site=<id></code>: <code>BookPage</code> with <code>profile="abc"</code> the person may see), so the Books area can show them without putting them on the library's shelf.</li> <li>Studio: <code>web/packages/ui/src/books/AbcWizard.tsx</code>, routed from the Books area in <code>web/studio/src/App.tsx</code> ("New ABC book" and an "ABC books" list per site). Fields as the Rails form plus title/subtitle and lettering; art styles as cards (name, summary, best for); theme as a combobox of bundled themes with the hint that any other theme is written by the model as a run. "Preview" shows the cover and the 26 plates (letter, word, tagline, alt, image path, prompt collapsed), the warnings, and the page Markdown and sidecar JSON as tabs. "Create book" opens the draft in the page editor; "Export to site" follows the job's log and ends with the files written and "<N> illustrations to render" plus the render step (drsai's <code>tools/generate_illustrations.py --book <slug></code> until <code>media.generate</code> exists).</li> <li>Extension: the same workspace in a webview at G10; until then record <code>extension: missing</code> on <code>books.abc</code> as the gap.</li> <li>Tests: <code>content/tests/books/test_api.py::test_the_abc_catalog_lists_styles_options_and_themes</code>, <code>::test_an_abc_preview_returns_the_spec_and_writes_nothing</code>, <code>::test_an_abc_preview_of_an_unbundled_theme_is_a_run</code> (recorded provider), <code>::test_an_abc_preview_refuses_an_invalid_spec_with_its_reasons</code>, <code>::test_an_abc_book_is_created_as_a_draft_with_26_letters</code>, <code>::test_an_abc_export_writes_only_into_a_registered_sites_checkout</code> (refuses an unregistered path; a hand-edited target file is a conflict; the two files land on success); <code>web/packages/ui/test/books.test.tsx</code> cases "the ABC wizard previews 26 plates and creates the book" and "an ABC export shows the files written and the illustrations to render". Proofs for <code>books.abc</code> <code>api:</code> and <code>studio:</code>.</li> <li>Milestone: G9 (its gate names "the Rails wizard's fixtures"; the box "The ABC wizard and drsai's story engine as book types and generators" is open). The export action depends on G4's write-back.</li> </ul> <p><strong>Keep</strong> — nothing under <code>rails/app</code> is data. The form's copy (hints, error messages, the next-step commands) is quoted above; the integration tests are mapped into the tests above (git history keeps the Ruby).</p> <h2 id="railsabc-generator">rails.abc-generator<a class="headerlink" href="#railsabc-generator" title="Permanent link">¶</a></h2> <p><strong>Did</strong></p> <ul> <li>Layout: <code>rails/lib/zer0_cms/abc.rb</code> (<code>SERIES = "abc-language"</code>), <code>abc/spec.rb</code>, <code>abc/lexicon.rb</code> + <code>abc/lexicons/*.yml</code>, <code>abc/content_provider.rb</code>, <code>abc/providers/{deterministic,anthropic}.rb</code>, <code>abc/art_styles.rb</code> + <code>data/abc_art_styles.yml</code>, <code>abc/wizard.rb</code>, <code>abc/jekyll_exporter.rb</code>; stdlib only. Contract: <code>rails/schema/abc-book.schema.json</code>.</li> <li>The ABC Book Spec (<code>spec.rb</code>, <code>SPEC_VERSION = 1</code>): fields and defaults <code>series</code> (<code>abc-language</code>), <code>slug</code>, <code>title</code>, <code>subtitle</code>, <code>theme</code>, <code>audience</code> (<code>toddler</code>), <code>language</code> (<code>en</code>), <code>art_style</code>, <code>palette</code>, <code>background</code> (<code>plain</code>), <code>mood</code> (<code>playful</code>), <code>lettering</code>, <code>art_style_prompt</code>, <code>generator</code>, <code>cover {subject, prompt, image, alt}</code>, <code>alphabet [ {letter, word, subject, tagline, alt, prompt, image, status} ]</code>. Serialised in exactly that key order with <code>spec_version</code> first, nil and empty values dropped; <code>from_json</code>/<code>from_yaml</code> round-trip. <code>validate!</code> collects every error and raises <code>InvalidSpec "invalid ABC Book Spec: <e1>; <e2>…"</code>: slug required and <code>^[a-z0-9]+(?:-[a-z0-9]+)*$</code>; title required; art_style required; audience in <code>toddler|preschool|early-reader</code>; alphabet 1–26 entries; each entry has non-blank <code>letter</code>, <code>word</code>, <code>subject</code>, <code>tagline</code>; letter is one of A–Z; no duplicate letter.</li> <li>The JSON Schema (draft-07): required <code>spec_version</code> (const 1), <code>series</code>, <code>slug</code> (pattern above), <code>title</code>, <code>audience</code> (enum), <code>art_style</code>, <code>alphabet</code>; <code>additionalProperties: false</code> at every level; <code>palette</code> string or null (null = style default); <code>cover</code> object of <code>subject, prompt, image, alt</code>; <code>alphabet</code> 1–26 items, each requiring <code>letter</code> (<code>^[A-Z]$</code>), <code>word</code>, <code>subject</code>, <code>tagline</code>, optional <code>prompt</code>, <code>image</code> ("leading slash, site-relative"), <code>alt</code>, <code>status</code> (<code>planned|rendered</code>, default planned). Duplicate letters are a code-only rule (the schema cannot say it). Nothing in Rails validates against the schema file itself; <code>spec.rb</code> mirrors it.</li> <li>Lexicons (<code>lexicon.rb</code>): YAML <code>{theme, title, subtitle, default_art_style, default_palette, audience, letters: {A..Z: {word, subject, tagline, alt}}}</code>. Lookup by <code>slugify(theme)</code> = lower-case, runs of non-<code>[a-z0-9]</code> → <code>_</code>, trimmed (so "IT systems", "it_systems" and "IT Systems" all find <code>it_systems.yml</code>); <code>available</code> = sorted basenames; a file missing any letter → <code>ArgumentError "lexicon <theme> is missing letters: …"</code>; an unknown theme → <code>UnknownTheme "no bundled lexicon for theme … (looked for <slug>.yml; available: …)"</code>. One lexicon ships: <code>it_systems</code> ("The IT Alphabet", "A is for Automation", <code>isometric-tech-toy</code>, <code>cool-tech</code>, toddler; Automation, Backup, Cloud, Database, Encryption, Firewall, Gateway, Hardware, Internet, JSON, Kernel, Logs, Memory, Network, Open Source, Password, Queue, Router, Server, Terminal, Update, Version, Wi-Fi, eXit, YAML, Zero Trust), every tagline "<L> is for <Word> — …".</li> <li>Providers (<code>content_provider.rb</code>): a registry by name (<code>deterministic</code>, <code>anthropic</code>; an unknown name → <code>ArgumentError "unknown content provider … (known: …)"</code>). <code>plan(theme:, audience:)</code> returns <code>{title, subtitle, default_art_style, default_palette, letters: {A..Z: {word, subject, tagline, alt}}}</code>; every provider runs <code>validate_plan!</code> (all 26 letters present as objects, <code>word</code>/<code>subject</code>/<code>tagline</code> non-blank, else <code>ArgumentError</code>). Deterministic: the lexicon's title, subtitle, defaults and letters (the lexicon's <code>audience</code> is not passed on). Anthropic (<code>providers/anthropic.rb</code>): one Messages call, <code>max_tokens 4096</code>, default model <code>claude-opus-5-5</code>, system "You write gentle, wholesome content for a children's ABC picture book. Every word is text-free and safe for toddlers.", user prompt "Design a <audience> ABC book on the theme "<theme>". For every letter A through Z, choose: word (a real concept from the theme starting with that letter), subject (a concrete, drawable little scene, no text), tagline (one warm read-aloud line, e.g. "A is for Automation — little helpers that do the work!"), alt (a short accessible description). Also give the book a title and a subtitle of the form "A is for <the A word>". Keep every word gentle and never scary. Return all 26 letters.", structured output by JSON Schema (<code>title</code>, <code>subtitle</code>, <code>letters</code> with all 26 keys, each <code>{word, subject, tagline, alt}</code> required, no extra properties); <code>default_art_style</code>/<code>default_palette</code> forced to nil. Errors as <code>ProviderError</code>: no credential ("needs ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN (or use the deterministic provider)"), <code>stop_reason: refusal</code> ("Claude refused the request; pick a different theme"), no text block, unparsable JSON, non-2xx ("Anthropic API error <code>: <first 300 chars>"). Credentials, headers and the OAuth "You are Claude Code" block are Rails plumbing the platform's provider registry replaces.</li> <li>Art styles (<code>art_styles.rb</code> over <code>data/abc_art_styles.yml</code>): catalog <code>version: 1</code>; six styles <code>isometric-tech-toy</code> (cool-tech, rounded), <code>chalkboard-doodle</code> (bright-primary, chalk), <code>soft-plush</code> (nursery-pastel, bubble), <code>crayon-primary</code> (bright-primary, slab), <code>paper-cutout</code> (warm-earth, rounded), <code>watercolor-storybook</code> (warm-earth, rounded), each <code>{id, name, summary, prompt, default_palette, default_lettering, best_for}</code>; options <code>palettes</code> (cool-tech, bright-primary, nursery-pastel, warm-earth), <code>backgrounds</code> (plain, scene, pattern), <code>moods</code> (playful, calm, bold), each with a prompt <code>fragment</code>, and <code>lettering</code> (rounded, bubble, slab, chalk: a hint for the theme's HTML letter, no fragment); <code>safety_suffix</code> (no text, toddler-safe). Style ids are a cross-repo contract (front matter <code>art_style:</code>, the theme's <code>abc-style--<id></code> class). <code>render_prompt(letter, word, subject, style, palette = style default, background = plain, mood = playful)</code> = the parts <code>[style prompt, background fragment, palette fragment, "Subject: <subject>, standing for the word <WORD upper-cased> (letter <L>).", mood fragment, safety_suffix]</code>, nils and empties dropped, joined with <code>". "</code>, <code>/\.\s*\./</code> → <code>.</code>, every whitespace run collapsed to one space, stripped. An unknown style raises <code>UnknownStyle</code>; an unknown palette, background or mood id silently adds nothing. <code>to_menu</code> = <code>{version, styles: [{id, name, summary, default_palette, default_lettering, best_for}], palettes|backgrounds|lettering|moods: [{id, name}]}</code>.</li> <li>Wizard (<code>wizard.rb</code>), given <code>theme</code> and optional <code>slug, title, subtitle, art_style, palette, background (plain), mood (playful), lettering, audience, language (en), provider (auto), assets_prefix (/assets/images/books)</code>: provider <code>auto</code> = deterministic when a lexicon exists, else anthropic with the warning "no bundled lexicon for "<theme>"; using the Anthropic provider"; <code>deterministic</code>/<code>anthropic</code> forced; anything else <code>ArgumentError</code>. Art style = caller's, else the plan's default, else <code>isometric-tech-toy</code>; unknown → warning "unknown art style "<id>"; falling back to isometric-tech-toy". Palette resolved once = caller's, else the plan's default, else the style's default, and used for the metadata, every letter and the cover (the regression the Rails test pins). Slug = caller's, else <code>slugify(plan title || caller title || theme)</code> with <code>-</code> (quirk: the plan's title wins over the caller's for the slug, so the auto IT book is <code>the-it-alphabet</code>). Title = caller's, else the plan's, else "The <theme> Alphabet"; subtitle = caller's, else the plan's; audience = caller's, else toddler; lettering = caller's, else the style's default; <code>art_style_prompt</code> = the style prompt squished; <code>generator</code> = "Text generated by the zer0-CMS ABC wizard from <the bundled <theme> lexicon | Claude (Anthropic)>; illustrations composed for the zer0-image-generator plugin and rendered by drsai." Each letter A–Z: <code>{letter, word, subject, tagline, alt (lexicon's, else "<word>, illustrated for the letter <L>."), prompt (render_prompt with the resolved palette, background, mood), image "<prefix>/<slug>/<l>-<slugify(word)>.png", status "planned"}</code>. Cover: subject "a joyful cover for an alphabet book about <theme>, a big friendly letter A and a smiling <first word>", prompt with letter A, the first word, background <code>scene</code>, the resolved palette and mood; image <code><prefix>/<slug>/cover.png</code>; alt "Cover of <title>.". Then <code>validate!</code>.</li> <li>Jekyll exporter (<code>jekyll_exporter.rb</code>): validates, then writes <code><root>/pages/_books/<slug>/index.md</code> (collections dir fixed to <code>pages</code>, not read from <code>_config.yml</code>) and <code><root>/_data/abc_books/<slug>.json</code> (the spec, pretty JSON, trailing newline), creating directories and overwriting without any check; returns both paths and the planned images (every letter not <code>rendered</code>, plus the cover: 27 for a new book). Page = YAML front matter in this order, nils dropped: <code>title, subtitle, layout: book-abc, book: <slug>, series, audience</code> (label: toddler "Ages 1–4 (toddler board book)", preschool "Ages 3–5 (preschool)", early-reader "Ages 5–7 (early reader)"), <code>status</code> (<code>complete</code> when every letter is rendered, else <code>illustrations-planned</code>), <code>art_style, art_style_prompt, palette, lettering, cover_image, cover_prompt, preview</code> (= cover image), <code>description</code> ("A <audience id> ABC picture book about <theme>: one letter, one word, one picture per page — from <A's tagline>"), <code>generator, alphabet: [{letter, word, tagline, image, alt, prompt, status}]</code> (no <code>subject</code> on the page); then <code>---</code>, a blank line and one fixed paragraph: "A first alphabet about <strong><theme></strong> — one big friendly letter per page, a word to say out loud, and a picture to point at. Read it top to bottom, or jump to any letter."</li> <li>Image-generator link: Rails renders nothing. The prompts are complete and text-free; drsai's <code>tools/generate_illustrations.py</code> renders every <code>alphabet</code> entry with a <code>prompt</code> and <code>image</code> whose file is missing (and the cover, portrait) and never edits front matter. drsai's <code>tools/import_abc_book.py --check</code> (CI <code>drsai.yml</code>, "ABC books match their spec") fails when the page and its sidecar disagree on <code>series, art_style, art_style_prompt, palette</code>, <code>cover_image</code>/<code>cover_prompt</code>, or any letter's <code>word, tagline, image, alt, prompt</code>, or on duplicate, missing or extra letters. Any exporter must therefore write the page and the sidecar together.</li> <li>CLI (<code>rails/bin/zer0-cms</code>): <code>styles</code> prints "ABC art styles (id — name):", each <code>id</code> padded to 22 with its name, <code>[palette: <default>]</code> and the summary, then <code>Options: palette=… | background=… | mood=…</code>; <code>themes</code> prints "Bundled A–Z lexicons (offline themes):", each slug padded to 16 with "<title> — <theme>", then the Claude-fallback note; <code>new --theme THEME [--slug] [--title] [--subtitle] [--art-style ID] [--palette ID] [--background ID] [--mood ID] [--audience] [--provider auto|deterministic|anthropic] [--out DIR (default .)] [--print]</code>: no <code>--theme</code> → "error: --theme is required (see <code>zer0-cms themes</code>)" exit 1; warnings to stderr as "note: …"; <code>--print</code> prints the page Markdown and writes nothing; otherwise "✓ wrote <page>", "✓ wrote <spec>", "<N> illustration(s) to render:" with the first three and "…", then "Next: render the plates in drsai —" and the <code>generate_illustrations.py --book <slug> --dry-run</code> line. <code>--out</code> has none of the web target checks. Unknown command → usage, exit 1. Rake wrappers <code>abc:styles</code>, <code>abc:themes</code>, <code>abc:new THEME= STYLE= SLUG= PALETTE= PROVIDER= OUT= PRINT=</code> (<code>rails/lib/tasks/abc.rake</code>).</li> <li>Tests (<code>rails/test/zer0_cms/test_abc_engine.rb</code>, CI <code>abc-engine.yml</code>): the IT lexicon covers A–Z with "<L> is for" taglines; theme lookup is slug-insensitive; an unknown theme raises; the deterministic plan has 26 letters, A = Automation, default style <code>isometric-tech-toy</code>; the registry knows both providers; the six style ids exist; <code>render_prompt</code> is deterministic, contains "no text" and "AUTOMATION"; the wizard yields a valid 26-letter spec (series, slug, style); every letter has a prompt, an image under <code>/assets/images/books/it-alphabet/<l>-</code> and status planned; the cover image is <code>…/it-alphabet/cover.png</code>; an unknown style falls back with a warning; <code>auto</code> on a bundled theme needs no key; with <code>watercolor-storybook</code> and no palette, the palette is <code>cool-tech</code> and every letter and the cover prompt contain "sky blue" and none "terracotta"; a bad slug is invalid; the spec round-trips through JSON; the export writes a parseable page (layout <code>book-abc</code>, series <code>abc-language</code>, 26 letters, every prompt "no text") and a sidecar with <code>spec_version: 1</code>, and lists 27 planned images.</li> </ul> <p><strong>Platform today</strong></p> <ul> <li><code>content/agents/handlers/abc.py</code> (the drafter's <code>abc</code> profile): lexicon lookup with the same <code>_</code> slug and the 26-letter completeness check, from <code>content/agents/data/abc_lexicons/</code>; theme from <code>run.input.theme</code>, else <code>front_matter.theme</code>, else the page title; one <code>letter</code> block <code>{letter, word, tagline, subject, alt, image: None}</code> per letter the page lacks (letters it has are kept — a platform improvement); at policy <code>suggest</code> one Suggestion per letter, at <code>draft</code> one revision; output <code>{theme, provider: "lexicon", letters_added, suggestions | revision_id}</code>. An unbundled theme falls to <code>model_loop</code> with the drafter's generic brief prompt: through the provider registry (<code>content/agents/llm.py</code>, <code>content/ai/providers/</code>, so no direct SDK call), but with no ABC prompt, no plan schema, no 26-letter validation and no recording (<code>content/agents/recordings/drafter/</code> has none for it).</li> <li>Model: <code>BookPage</code> (<code>content/cms/models.py</code>) has <code>subtitle, author, series, profile (book|abc|story), audience, art_style</code>; no theme, language, palette, background, mood, lettering, cover or generator. <code>LetterBlock</code> (<code>content/cms/blocks.py</code>): <code>letter</code> <code>^[A-Z]$</code>, <code>word</code> ≤80, <code>tagline</code> ≤250, optional <code>subject</code> ≤400, <code>alt</code> ≤250, <code>image</code> (a Wagtail image); no <code>prompt</code>, image path or <code>status</code>. The handler sets none of the book fields.</li> <li>Import (<code>content/importers/jekyll.py</code>): <code>layout: book-abc</code> or an <code>alphabet:</code> → <code>profile="abc"</code>, each entry → a <code>letter</code> block (truncated to the field limits), the book fields from front matter. Export (<code>content/exporters/jekyll.py::_alphabet</code>, <code>front_matter_for</code>): <code>layout: book-abc</code> by default, the <code>alphabet:</code> rebuilt from the <code>letter</code> blocks merged into the source's entries (keeping <code>image</code>, <code>prompt</code>, <code>status</code>; overwriting <code>word</code>, <code>tagline</code>, <code>alt</code>; <code>subject</code> only when the entry has no prompt), path <code><collections_dir>/_books/<slug>/index.md</code>; an unchanged page exports verbatim. Missing: the cover, <code>book/status/art_style_prompt/palette/lettering/cover_*/preview/description/generator</code> for a book made in the platform, prompts and image paths for a letter or a book made in the platform, the audience labels, the body paragraph, and a sidecar for a book made in the platform.</li> <li>Built for an edited letter: <code>content/books/abc.py</code> has <code>render_prompt</code> (the exact algorithm, over a vendored <code>content/books/data/abc_art_styles.yml</code>) and the image path, and the export plans a plate whose word or subject changed again — image <code><old folder>/<l>-<word slug>.png</code>, prompt recomposed, status <code>planned</code> — and writes the sidecar, read on import onto <code>ImportedSource.sidecars</code>, verbatim while the book is unchanged and otherwise agreeing with the page; the write-back indexes, guards and records it (<code>content/tests/books/test_abc.py</code>, golden <code>content/tests/fixtures/abc/</code>, drsai's <code>import_abc_book.py --check</code> as the oracle).</li> <li>Nothing on the platform reads <code>abc-book.schema.json</code>; there is no <code>manage.py</code> command for styles, themes or a new book.</li> <li>Tests that exist: <code>content/tests/agents/test_drafter.py::test_the_abc_profile_writes_every_missing_letter_from_the_lexicon</code>, <code>content/tests/agents/test_drafter.py::test_an_unknown_abc_theme_falls_back_to_the_model</code> (only that it fails without a recording), <code>content/tests/agents/test_drafter.py::test_at_policy_draft_the_abc_drafter_writes_the_revision_itself</code>, <code>content/tests/cms/test_models.py::test_book_pages_take_chapters_and_letter_blocks</code>, <code>content/tests/importers/test_jekyll.py::test_each_file_becomes_the_right_page</code>, <code>content/tests/importers/test_jekyll.py::test_an_edited_page_exports_its_edits_over_its_front_matter</code>, <code>content/tests/importers/test_jekyll.py::test_the_real_sites_round_trip_byte_for_byte[sites/drsai]</code> (drsai's <code>it-alphabet</code> page round-trips unchanged); the drafter eval <code>abc-it-systems</code> (26 inserts). Vendored-copy drift is <code>bin/zer0 check</code>'s.</li> </ul> <p><strong>Verdict</strong> — <code>specified</code>: the platform writes the lexicon's letters and plans an edited plate again (its sidecar with it), nothing more — no spec, validation, art direction for a new book, cover, model plan contract or CLI.</p> <p><strong>Build</strong></p> <ul> <li>Engine: <code>content/books/abc.py</code>, pure functions the API, the command and the drafter handler share (move <code>lexicon()</code>/<code>available()</code> here from <code>agents/handlers/abc.py</code>): <code>catalog()</code> (the menu above, from <code>content/books/data/abc_art_styles.yml</code>), <code>render_prompt(...)</code> (the exact algorithm above), <code>plan(theme, provider)</code> → <code>(plan, warnings)</code>, <code>build_spec(theme, **choices)</code> → <code>(spec, warnings)</code> with the resolution rules above (fix the slug quirk only by an explicit decision: the golden needs <code>slug</code> passed), <code>validate(spec)</code> = <code>Draft7Validator</code> over <code>schemas/books/abc-book.schema.json</code> plus the duplicate-letter rule, with the Rails messages, <code>render_page(spec)</code>, <code>sidecar(spec)</code> = <code>json.dumps(spec, indent=2, ensure_ascii=False) + "\n"</code> (verified byte-identical to the Ruby output on the golden), <code>planned_images(spec)</code>. The model path is the drafter's <code>abc</code> profile run: the Rails system and user prompts as the profile's prompt, the plan JSON Schema as the run's output <code>schema</code> (through <code>model_loop</code>/<code>ai</code> — the registry, budgets, schema validation), <code>validate_plan</code> on the result; refusal, no text and bad JSON fail the run with the Rails messages; a recording under <code>content/agents/recordings/drafter/abc-model/</code>. The handler also fills the book's fields (subtitle, series <code>abc-language</code>, art style, the knobs) from the plan on a new book.</li> <li>Model: the book-level knobs <code>theme</code>, <code>language</code>, <code>palette</code>, <code>background</code>, <code>mood</code>, <code>lettering</code> (and the cover subject) become <code>BookPage</code> data the studio edits — typed fields, or one <code>abc</code> JSON field validated by the schema's book-level subset; <code>art_style_prompt</code>, every <code>prompt</code>, <code>image</code> path and the cover are derived, never typed by a person.</li> <li>Exporter (<code>content/exporters/jekyll.py</code>, G4's <code>site_files</code>): for <code>profile="abc"</code>, the full front matter in the Rails key order with the audience labels, status and body paragraph, and a second file <code>_data/abc_books/<slug>.json</code>; a letter whose word or subject, or a book whose style knobs, differ from what its source entry was composed from gets its <code>prompt</code> and <code>image</code> recomposed, otherwise the source's are kept (so drsai still round-trips byte for byte); <code>status</code> stays as imported unless the word changed (<code>planned</code>) or the <code>letter</code> block has an image (<code>rendered</code>). Use the site's <code>collections_dir</code>, not a hard-coded <code>pages</code>.</li> <li>Command: <code>manage.py abc styles | themes | new</code> (<code>content/books/management/commands/abc.py</code>) with the Rails flags and output; <code>new</code> takes <code>--site KEY</code> (a registered site: writes through the write-back) or <code>--out DIR</code> (only a Jekyll root with a regular <code>_config.yml</code>, the <code>AbcExportTarget</code> rules) or <code>--print</code>; <code>--provider auto|lexicon|model</code> (<code>deterministic</code>/<code>anthropic</code> accepted as aliases); exit 1 on a missing <code>--theme</code> or an invalid spec.</li> <li>API / Studio / Extension: the wizard row's Build (this row adds no surface of its own beyond the command).</li> <li>Tests (<code>content/tests/books/test_abc.py</code> unless noted): <code>test_the_it_alphabet_sidecar_is_byte_identical_to_the_rails_golden</code> (<code>content/tests/fixtures/abc/_data/abc_books/it-alphabet.json</code>; theme "IT systems", slug <code>it-alphabet</code>, style <code>isometric-tech-toy</code>, lexicon); <code>test_the_it_alphabet_page_matches_the_rails_golden</code> (front matter equal as data in key order, body identical — PyYAML and Psych quote <code>/…</code> strings differently, so not bytes); <code>test_every_spec_and_the_golden_validate_against_the_abc_book_schema</code>; <code>test_spec_validation_rejects_bad_input</code> (parametrised: slug "Not A Slug", no title, no art style, audience "adult", 0 and 27 letters, a duplicate A, letter "a", a blank tagline — each with its message); <code>test_render_prompt_is_text_free_and_deterministic</code> (equals the golden's A prompt); <code>test_the_catalog_keeps_the_six_cross_repo_style_ids</code>; <code>test_an_unknown_art_style_falls_back_with_a_warning</code>; <code>test_the_palette_is_consistent_across_letters_cover_and_metadata</code> (watercolor-storybook → cool-tech, "sky blue" everywhere, no "terracotta"); <code>test_a_new_book_plans_a_cover_and_27_images</code>; <code>test_lexicon_lookup_ignores_case_and_spacing_and_refuses_a_missing_letter</code>; <code>test_auto_uses_the_lexicon_offline_and_the_model_otherwise</code> (fake provider: the plan schema was sent, 26 letters, the warning); <code>test_a_model_plan_missing_a_letter_or_refused_fails_the_run</code>; <code>content/tests/importers/test_jekyll.py::test_an_abc_book_made_in_the_platform_exports_its_page_and_sidecar</code>; <code>content/tests/books/test_abc.py::test_an_edited_word_exports_a_plate_planned_for_it_and_a_sidecar_that_agrees</code> (built; oracle: drsai's <code>import_abc_book.py --check</code>); <code>content/tests/books/test_commands.py::test_abc_styles_themes_and_new_print</code>; a drafter eval <code>abc-model</code> on the recording. Then <code>rails.abc-generator</code> and <code>imagegen.abc-art-styles</code> can be <code>done</code> on these proofs.</li> <li>Milestone: G9.</li> </ul> <p><strong>Keep</strong> — done when <code>rails/</code> was deleted, or recorded here instead of copied:</p> <ul> <li>The lexicon: <code>content/agents/data/abc_lexicons/it_systems.yml</code> was a byte-identical vendored copy of <code>rails/lib/zer0_cms/abc/lexicons/it_systems.yml</code>, the only lexicon on either side; the <code>vendored:</code> entry is gone and the platform copy is the source.</li> <li>The art styles: <code>rails/lib/zer0_cms/data/abc_art_styles.yml</code> was itself a vendored copy of <code>packages/zer0-image-generator/lib/zer0_image_generator/abc/art_styles.yml</code>, which stays. Copy it into <code>content/books/data/abc_art_styles.yml</code> when this is built, and before G11 deletes the package; fix its header there, which still says the Rails copy points back at it.</li> <li>The schema: <code>rails/schema/abc-book.schema.json</code> is now <code>schemas/books/abc-book.schema.json</code> (its description no longer names the Rails module; its <code>$id</code> is unchanged and unpublished). Nothing validates against it yet; the generator built here validates every spec it writes, and the golden, against it.</li> <li>The goldens: drsai's committed <code>sites/drsai/_data/abc_books/it-alphabet.json</code> and <code>sites/drsai/pages/_books/it-alphabet/index.md</code> at <code>d0a572fb</code> are the Rails generator's exact output (regenerated byte for byte from that commit's <code>rails/lib</code> with <code>theme "IT systems", slug it-alphabet, art_style isometric-tech-toy, provider deterministic</code>). Freeze them as <code>content/tests/fixtures/abc/</code> from that commit when the tests above are written — drsai's own copies change when plates are rendered. More goldens can be recorded from git history: <code>git archive d0a572fb rails/lib</code> and Ruby 3.0 or newer.</li> </ul> <h2 id="found-while-writing-this-spec">Found while writing this spec<a class="headerlink" href="#found-while-writing-this-spec" title="Permanent link">¶</a></h2> <p>User-visible behaviour of <code>rails/app</code>, <code>rails/config</code> and <code>rails/lib/zer0_cms</code> (ABC, LinkedIn and distribution excluded) that no <code>sources:</code> row names or that a <code>done</code> row hides, and platform bugs the comparison turned up. None of it is fixed by the change that deleted <code>rails/</code>:</p> <ul> <li><strong>Rails' page edit form edited keys the studio cannot</strong> (<code>page_dashboard.rb</code> <code>FORM_ATTRIBUTES_EDIT</code>, <code>page_editor.rb</code>):</li> <li><code>layout</code>, <code>permalink</code>, <code>status</code>, <code>preview</code> and <code>published</code>/<code>draft</code> (the last as checkboxes).</li> <li>A "Not editable here (structured values): …" notice for keys holding maps or lists of maps.</li> <li>Emptying a field deleted the key.</li> <li>The studio's editor fields (<code>cms/models.py</code> <code>shared_editor_fields</code> + <code>ArticlePage.editor_fields</code>) cover title, slug, SEO, AI fields, date, author, tags and categories only. <code>preview_image</code> is not an editor field, and raw front matter is "to come" (content.edit).</li> <li>G4 marks <code>rails.page-edit</code> done. Its proof covers the file write, not these fields. Track them under content.edit (P4), or reopen that row.</li> <li><strong>The page "file facts" view</strong> (<code>SHOW_PAGE_ATTRIBUTES</code>): source path; front matter as indexed (pretty JSON); file bytes, mtime, SHA-256; the parse error. The studio shows none of them.</li> <li>Nearest row: content.edit (raw front matter).</li> <li>Proposal: a read-only "Source" tab in the page editor, showing <code>legacy_path</code>, <code>front_matter</code> and the <code>ImportedSource</code> digest.</li> <li><strong>Fixed: unpublishing in the studio unpublishes the Jekyll file.</strong> Every write-back, not only "drafts too", gives a page that is not live <code>published: false</code> (what Rails' <code>published</code> checkbox wrote) under the stale-write guard and takes it off when the page goes live again — <code>content/tests/sites/test_sites.py::test_unpublishing_a_live_page_takes_its_file_down_and_republishing_restores_its_bytes</code>.</li> <li><strong>No producer of <code>app.user.interaction</code>.</strong></li> <li>The graph's behavioural edges (<code>content/graph/consumers.py</code>, <code>build_viewed_together</code>) consume an event that nothing emits, and Rails never emitted it.</li> <li>The producer belongs to the public site, through the P6 renderer, with an anonymous rotating <code>anon_id</code> and a beacon endpoint.</li> <li>No row tracks it. Suggest one under sites.analytics.</li> <li><strong>Fixed: future-dated posts and <code>status: draft</code> files import as not live</strong> (rails.page-search's decision): a page is live exactly when the catalog's <code>Entry.live</code> says the site builds the file — <code>published: false</code>, <code>draft: true</code>, <code>status: draft</code> and <code>_drafts/</code> are drafts, a file dated in the future is scheduled for its date unless <code>_config.yml</code> sets <code>future: true</code> (<code>content/tests/importers/test_jekyll.py::test_a_file_the_site_does_not_build_imports_as_a_draft_or_scheduled</code>).</li> <li><strong>Fixed: the importer finds previews under <code>assets/</code>, and SVG previews</strong> (rails.assets-terms): <code>importers.jekyll.preview_file</code> tries the source, <code>source/assets</code> and the root, each confined by <code>sites/writer.py</code>, and an SVG is a Wagtail image like any other (<code>content/tests/importers/test_jekyll.py::test_a_preview_under_assets_is_found_like_the_engine_finds_it</code>).</li> <li><strong>Root <code>/</code> redirects to <code>/admin</code>; <code>/up</code> is Rails' health check.</strong> Covered by platform.ops (<code>/healthz</code>, <code>/readyz</code>, <code>/version</code>; <code>content/tests/ops/test_health.py</code>). Nothing to build.</li> <li><strong>The "Image generator ↗" link-out</strong> (sidebar, site page, page page; <code>ZER0_IMAGE_GENERATOR_URL</code>, only <code>http(s)</code> accepted, default <code>http://localhost:3000</code>) is covered by the imagegen.* rows (G6's Media area). Nothing to build.</li> </ul><aside class="brain-panel" data-brain-path="zer0-CMS/docs/plan/rails-cms-spec.md"><p class="brain-source">Source: <a href="https://github.com/bamr87/zer0-CMS/blob/main/docs/plan/rails-cms-spec.md">bamr87/zer0-CMS</a></p><details open><summary>Backlinks (2)</summary><ul><li><a href="../../amendments/0002-retire-the-rails-invariants/">0002 — Retire the Rails invariants</a><span class="brain-origin">zer0-CMS</span></li><li><a href="../../adr/0008-retire-the-rails-cms/">ADR 0008 — Retire the Rails fleet CMS now: merge G4 and G5, delete `rails/`, and keep what it still owes as a spec</a><span class="brain-origin">zer0-CMS</span></li></ul></details><details><summary>Outgoing links (1)</summary><ul><li><a href="../../adr/0008-retire-the-rails-cms/">ADR 0008 — Retire the Rails fleet CMS now: merge G4 and G5, delete `rails/`, and keep what it still owes as a spec</a><span class="brain-origin">zer0-CMS</span></li></ul></details></aside> </article> </div> <script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script> </div> <button type="button" class="md-top md-icon" data-md-component="top" hidden> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8z"/></svg> Back to top </button> </main> <footer class="md-footer"> <div class="md-footer-meta md-typeset"> <div class="md-footer-meta__inner md-grid"> <div class="md-copyright"> <div class="md-copyright__highlight"> Copyright © 2025 Amr Abdel-Motaleb </div> Made with <a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener"> Material for MkDocs </a> </div> <div class="md-social"> <a href="https://github.com/bamr87" target="_blank" rel="noopener" title="github.com" class="md-social__link"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2025 Fonticons, Inc.--><path d="M173.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6m-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3m44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9M252.8 8C114.1 8 8 113.3 8 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C436.2 457.8 504 362.9 504 252 504 113.3 391.5 8 252.8 8M105.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1m-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7m32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1m-11.4-14.7c-1.6 1-1.6 3.6 0 5.9s4.3 3.3 5.6 2.3c1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2"/></svg> </a> <a href="https://linkedin.com/in/amrabdel" target="_blank" rel="noopener" title="linkedin.com" class="md-social__link"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2025 Fonticons, Inc.--><path d="M416 32H31.9C14.3 32 0 46.5 0 64.3v383.4C0 465.5 14.3 480 31.9 480H416c17.6 0 32-14.5 32-32.3V64.3c0-17.8-14.4-32.3-32-32.3M135.4 416H69V202.2h66.5V416zM102.2 96a38.5 38.5 0 1 1 0 77 38.5 38.5 0 1 1 0-77m282.1 320h-66.4V312c0-24.8-.5-56.7-34.5-56.7-34.6 0-39.9 27-39.9 54.9V416h-66.4V202.2h63.7v29.2h.9c8.9-16.8 30.6-34.5 62.9-34.5 67.2 0 79.7 44.3 79.7 101.9z"/></svg> </a> <a href="https://bashconsultants.com" target="_blank" rel="noopener" title="bashconsultants.com" class="md-social__link"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2025 Fonticons, Inc.--><path d="M351.9 280H161c2.9 64.5 17.2 123.9 37.5 167.4 11.4 24.5 23.7 41.8 35.1 52.4 11.2 10.5 18.9 12.2 22.9 12.2s11.7-1.7 22.9-12.2c11.4-10.6 23.7-28 35.1-52.4 20.3-43.5 34.6-102.9 37.5-167.4zm-191-48h190.9c-2.8-64.5-17.1-123.9-37.4-167.4-11.4-24.4-23.7-41.8-35.1-52.4C268.1 1.7 260.4 0 256.4 0s-11.7 1.7-22.9 12.2c-11.4 10.6-23.7 28-35.1 52.4-20.3 43.5-34.6 102.9-37.5 167.4m-48 0c3.5-85.6 25.6-165.1 57.9-217.3C78.7 47.3 10.9 131.2 1.5 232zM1.5 280c9.4 100.8 77.2 184.7 169.3 217.3-32.3-52.2-54.4-131.7-57.9-217.3zm398.4 0c-3.5 85.6-25.6 165.1-57.9 217.3 92.1-32.7 159.9-116.5 169.3-217.3zm111.4-48C501.9 131.2 434.1 47.3 342 14.7c32.3 52.2 54.4 131.7 57.9 217.3z"/></svg> </a> </div> </div> </div> </footer> </div> <div class="md-dialog" data-md-component="dialog"> <div class="md-dialog__inner md-typeset"></div> </div> <script id="__config" type="application/json">{"annotate": null, "base": "../../../..", "features": ["navigation.instant", "navigation.tracking", "navigation.tabs", "navigation.tabs.sticky", "navigation.sections", "navigation.path", "navigation.indexes", "navigation.prune", "toc.follow", "navigation.top", "search.suggest", "search.highlight", "search.share", "content.code.copy", "content.code.annotate"], "search": "../../../../assets/javascripts/workers/search.a7633da7.min.js", "tags": null, "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}, "version": null}</script> <script src="../../../../assets/javascripts/bundle.a5f9d56c.min.js"></script> <script src="../../../../assets/brain/brain.js"></script> <script src="../../../../assets/brain/workspace.js"></script> </body> </html>