Skip to content

content/ — the platform

The Django 5.2 + Wagtail 7.4 platform — pages and revisions, the agent harness and tool registry, suggestions, the graph, the outbox, the operational baseline, and its GraphQL, REST and MCP surfaces — and how to run it.

The Django 5.2 + Wagtail 7.4 project that is zer0-CMS (ADR 0001, ADR 0004): pages and their revisions, the agent harness and its one tool registry, suggestions, the content graph, the transactional outbox, the GraphQL, REST and MCP surfaces over all of it, and the operational baseline every one of them answers through. The Jekyll files stay the source of truth for a site until it cuts over (ADR 0002), and the importer and exporter keep both directions exact.

cd content
pip install -r requirements-dev.txt
pip install -r requirements-providers.txt                           # optional: the model providers' SDKs (ai/README.md)
python manage.py migrate && python manage.py sync_agents --publish   # agent users, definitions, evals → live
python manage.py import_jekyll --site drsai --path ../sites/drsai     # a site → pages
python manage.py seed_demo                                            # or a demo site, the person `editor` and suggestions to review
python manage.py createsuperuser && python manage.py runserver        # http://localhost:8000/studio/ (built in ../web), /admin/

python -m pytest -q -m "not slow"                  # the fast tier (SQLite, ~40 s)
python -m pytest -q                                # + round trips of the two big in-repo sites
DATABASE_URL=postgres://… python -m pytest -q      # the same suite on Postgres + pgvector
python -m pytest -q -n auto --maxschedchunk 1      # any of these on every core (pytest-xdist), as content.yml runs them
python manage.py makemigrations --check --dry-run
python manage.py run_evals --all --recorded        # every agent's eval suite, no network
python manage.py graphql_schema --out ../schemas/graphql/schema.graphql
python manage.py wagtail_ai_schema --out ../schemas/content/ai-schema.json
ruff check . && ruff format --check .

With Docker, from the repository root: docker compose --profile content up -d --wait starts Postgres (pgvector), Redis, this app on http://localhost:8000, a Celery worker and beat, a second worker for the research library's fetches (the research queue, so a slow site never holds the worker that runs agents and publishes), the outbox relay, the outbox desk's belt publisher (a consumer of this plane's own stream, outboxdesk/README.md), and events, the consumer that hands the platform's own events to its handlers here — distribution's drafts and the automations waiting for them. The web role is gunicorn on threaded workers, configured once in gunicorn.conf.py (gunicorn reads it from the working directory): a run's event stream holds a request for up to five minutes, which a sync worker cannot do — gunicorn kills it at its 30 s timeout mid-stream.

Apps

App What it owns Read first
config/ settings (base / development / production / testing, all from the environment), URLs, Celery config/settings/base.py
cms/ page types (SiteRootPage, CollectionPage, ArticlePage, StandardPage, BookPage, ChapterPage) and the fields a person edits on each (editor_fields; on every page the SEO and social fields beyond Wagtail's own — canonical_url, the Open Graph title, description and image, noindex — each its file's front-matter key, null while the page says what its file says, cms/seo.py; for a page that is a file of its own — ArticlePage, StandardPage — also that file's path and raw front matter, cms/files.py), the AgentManagedMixin, StreamField blocks (cms/blocks.py: Markdown, heading, paragraph, image, code, quote, page link, brief, letter, and Wagtail's table, typed table, embed — checked as a URL, never fetched — and document beside raw HTML, Liquid and an Obsidian callout), the image model, Category and BrandRules snippets, the content.* and media.* tools, the publish signal; the page services — save a draft, create, publish now, schedule a publish and an expiry (both carried out by Celery beat, cms/tasks.py, one page per transaction), unpublish, revert — each taking the page row's lock and honouring Wagtail's locks (writable); the pages a person finds (visible_pages); and manage.py seed_demo cms/models.py, cms/services.py, cms/blocks.py
agents/ definitions, runs (and AgentRun.objects.visible_to, the one scope every surface reads runs through: a person's own runs and the runs behind what they may review; each run's start, by whom, and finish, how, in Wagtail's log: zer0.run.start, zer0.run.finish), steps, memory, evals, tokens; the registry, the LLM layer, the runner, the schema export, agent principals; the YAML definitions and their recordings agents/README.md
ai/ the AI content layer: provider adapters behind one registry (the only place a vendor SDK is imported), the model catalog, output schemas, assistants, pipelines, briefs and conversations — every generation an agent run, every result reviewed ai/README.md
research/ the research library: sources (web pages fetched behind an SSRF guard, feed items, documents, notes) with extracted text, summaries and entities; quotes, citations, collections, feed subscriptions on beat; cited answers, fact-checks whose corrections are suggestions, web search through a provider's tool research/README.md
ideas/ boards of ideas: capture from anywhere, votes, brainstorms through the AI layer's conversations, clusters and duplicates by meaning, merging, promotion to a brief, an article or a book ideas/README.md
newsroom/ operating a news site: desks, stories (the budget and the calendar), assignments, the newsroom workflow on Wagtail's (editing and copy stages, embargoes, the breaking-news fast path), fronts, bylines and author pages, the corrections and updates log, newsletters with double opt-in through django-anymail, AI help through the AI layer, and parodynews's Parody desk (manage.py seed_parody_desk) newsroom/README.md
books/ books in the platform: a book's library/<slug>/ as a generated file set (import_books, export_books, roundtrip_books), the bookshelf's commands (manage.py books …: validation with its codes, statistics, manuscripts, the dashboard), and AI-assisted outlining and writing as runs of the books agent whose results are suggestions books/README.md
sites/ the sites the platform manages: ManagedSite (checkout, content source, renderer, domains, deploy target, the digests of its files, the doctor's findings) and per-site SiteSettings (with the site's brand rules: its voice and its banned phrases); the Jekyll 4.4 catalog, front-matter line surgery and the confined writer ported from the Rails catalog; sync, the write-back under the stale-write guard, and zer0 doctor as jobs sites/README.md
jobs/ Job, its log lines and artifacts: background work a person starts and follows live, and cancels jobs/README.md
distribution/ channels (LinkedIn with OAuth and PKCE, WordPress, GitHub pull requests, newsletters; credentials encrypted and write-only), the queue (compose → brand guard → a person's approval → publish on the worker, every gate checked twice, a channel armed by a person and the deployment), the ledger keyed by canonical URL in the extension's byte format, statistics on beat, the distribution.* tools and the published-page consumer; and manage.py linkedin, the LinkedIn lane over a site's own files for its CI distribution/README.md
automations/ automations: a trigger (an event the platform announces, a schedule, a signed webhook, a new research source, a named hook), a JMESPath condition and ordered actions (an assistant, a pipeline, an agent run, a brief, an idea, an email, a webhook, a newsroom stage) that run as their owner and never publish; paused when made, rate-limited, every run logged with its payload and each action's outcome — its owner's to read, however the automation is shared —; YAML export and import; the automations.fire_hook tool automations/README.md
aieo/ AIEO: the analyzers and the five-dimension citability score (heuristics, or a model's evaluation through the AI layer with the heuristics as its fallback), audits of a text, a page, a URL or a crawled site as runs (every fetch through the research library's guard), optimize, scrub and apply-a-pattern as suggestions, the editable pattern library, the AIEO agents as bundled assistants, citation tracking per engine on beat, GA4, Search Console and DataForSEO connectors, priorities, reports, the brand context, the LandingPage type, the aieo_* MCP names, manage.py aieo … aieo/README.md
suggestions/ Suggestion (and Suggestion.objects.visible_to, the one scope every surface reads suggestions through), BlockProvenance, the accept/reject flow, the brand guard (ported from the extension), the editor panel and views; each suggestion proposed, accepted and rejected is an entry in Wagtail's log (zer0.suggestion.*, by who did it) suggestions/services.py
graph/ Entity, Edge, Embedding, behavioural counts; structural edges, kNN, related, semantic search, GraphRAG graph/README.md
workflow/ AgentReviewTask, a Wagtail workflow task a review agent decides; the seeded "Editorial" workflow — the brand agent's review, then a moderator's approval — made and given to sites by manage.py seed_editorial [--site KEY …] (seed_demo gives it to the demo site) workflow/models.py, workflow/services.py
outbox/ OutboxEvent, ProcessedEvent, emit(), the relay to Redis Streams, deduplicating consumers outbox/README.md
outboxdesk/ the outbox desk: the outbox harness (bamr87/outbox) run from the platform — its belt of handoffs read through the library (the files are the record), sent on as the editor station and delivered by the worker; arena trials and claim checks run in the worker, resolved into Brier scores and calibration; a published handoff for every page that goes live, from the transactional outbox's event (ADR 0007) outboxdesk/README.md
api/ GraphQL additions (Grapple), REST endpoints, the CSRF-aware GraphQL view; the studio's endpoints — the session (session.py), sites, pages, revisions and publishing (pages.py), the review inbox (review.py), their shapes (serializers.py) — and the built studio at /studio/ (studio.py) api/views.py, api/pages.py
mcp_server/ MCP over Streamable HTTP (/mcp/) and stdio, over the one registry mcp_server/README.md
importers/ Jekyll sites (read by sites/catalog.py) and parodynews's dump → pages and the AI content layer; a body → blocks (markdown.py: a code fence, a heading, and a paragraph that a table, typed table, callout, embed, document, raw HTML or Liquid block writes back byte for byte becomes that block, the rest stays Markdown verbatim); ImportedSource (a page's file, and an ABC book's spec sidecar read with it) and ImportedRecord (an AI row's digest), so a re-import never overwrites what was changed here (--force aside); and the record read backwards — the pages a file became (services.pages_imported_from), which the extension opens for the open file importers/jekyll.py
accounts/ how people sign in (PLAN G3): django-allauth configured — local accounts by password or by a code sent by email, sign-up where SIGNUP_OPEN says, verification and password reset by code, TOTP, recovery codes and passkeys, OpenID Connect IdPs (one per OIDC_PROVIDERS id) and GitHub from the environment, the IdP's groups mapped onto Wagtail groups (OIDC_GROUP_MAP), the session list — served headless at /_allauth/browser/v1/ to the studio's sign-in and account menu; the Wagtail and Django admins' sign-in routed there; and UserToken (zer0u_…, hashed, expiring, scoped read/write), issued and revoked in the account menu (/api/v2/account/tokens/) or by manage.py user_token, accepted by REST and GraphQL; issuing and revoking one are entries in Wagtail's log (zer0.token.issue, .revoke: holder, name and prefix, never the token) accounts/README.md
exporters/ pages → Jekyll files: an unchanged imported page byte for byte, a changed one over its original file by line surgery (an SEO key only where a person changed its field), any other at its file path with its typed fields over its raw front matter; an edited ABC book's changed plates planned again and its spec sidecar written to agree (books/abc.py); a moved page's old file is listed, never deleted exporters/jekyll.py
ops/ the probes, the request id, JSON logging and redaction, the error envelope, throttling, CORS, security headers, the OpenAPI document, error reporting ops/README.md

How a change travels

editor or agent ──► tool (registry: schema, effect, policy, permission, rate) ──► Suggestion
                                                                                   │ editor accepts (one revision, agent-authored, with provenance)
                                                                                   ▼
                                     page revision ──► publish ──► graph index + outbox event (one transaction)
                                                                         │
                                       relay ──► Redis Stream zer0:content ──► consumers (distribution's drafts), …

Surfaces

Path What
/studio/ The studio (../web/, built into ../web/studio/dist, assets under /static/studio/): Write (with its AI panel), Create (pages, briefs, conversations), Review, Outbox (the outbox desk), and the AI area (agent runs, assistants, pipelines, output schemas, conversations, providers, models, automations); every path under it answers its index.html with an enforced, per-request-nonce CSP. 503 with the build command when it has not been built
/admin/ Wagtail: pages, the suggestions panel and view, snippets (agents, memory, entities, brand rules, categories), Reports → Agent runs — the operator fallback until the studio covers it (ADR 0006)
/graphql/ Grapple's schema for every page type, plus semanticSearch, graphSearch, related, entities, suggestions, agentRun, aiSchema; mutations requestAgentRun, acceptSuggestion, rejectSuggestion. The committed SDL is schemas/graphql/schema.graphql.
/api/v2/ Wagtail API v2 (pages, images, documents), agent-runs/ (create, list, read, stream/ as SSE — a browser's EventSource included), agents/<slug>/runs, graph/{neighbors,path,related,search}/, suggestions/, tools/; for people in the studio and the extension: me, session/{login,logout}, sites/, content/types/, content/pages/ (any status, filtered, paginated — source=<path> finds the pages a file was imported into; create as a draft) and per page types/, save a draft (PATCH, naming the revision it was edited from; fields by the names in field_specs, and for an ArticlePage or a StandardPage its file: file_path and the raw front_matter, every key no typed field writes, as a JSON object in order — cms/files.py), publish/, unpublish/, schedule/ (a time to go live, a time to come down, or both; a publish and a schedule name the revision the person reviewed, base_revision_id, and are refused with a 409 when a newer one exists), unschedule/, revisions/, revisions/compare/, revisions/<id>/revert/; review/suggestions/ (with diffs) and review/runs/<id>/accept/ (the ids a person saw). A run and a suggestion are named by their UUID public ids, in a path, a body, an answer and an event alike, and their integer keys never leave the platform; pages, revisions, sites and users keep Wagtail's and Django's integer ids (P-D6, ADR 0009). A person finds the pages Wagtail's explorer would show them, opens only those they may edit or publish, and cannot write a page a Wagtail lock keeps from them (409 resource.locked)
/api/v2/ai/ the AI content layer: providers/, models/, output-schemas/, assistants/, pipelines/, briefs/, conversations/, messages/ — runs answer 202 and are followed on agent-runs/<id>/stream/ (ai/README.md)
/api/v2/ideas/ ideas (capture/, brainstorm/, keep/, clusters/, and per idea vote/, merge/, promote/) and boards/ (ideas/README.md)
/api/v2/research/ collections/, sources/ (upload/, search/, and per source refetch/, summarize/), quotes/, citations/, feeds/, questions/, fact-checks/ (research/README.md)
/api/v2/newsroom/ the newsroom: desks/, stories/ (the budget and the calendar; move/, assign/, ai/, apply-draft/), authors/, fronts/, newsletters/, issues/ (preview/, send/), and the public subscribe/, subscriptions/confirm/ and subscriptions/unsubscribe/ (newsroom/README.md); the Wagtail page API carries every page's bylines and corrections. The pages a newsletter's emailed links open are /newsletters/confirm/ and /newsletters/unsubscribe/
/api/v2/books/ books: the library's shelf, a book's overview, chapters, its other files, findings, the manuscript, what a task's model reads, assist/ (a task, 202) and a book from a premise (books/README.md)
/api/v2/outbox/ the outbox desk: belt/ (the summary), belt/messages/ (filtered, paged; per message its CloudEvent), belt/traces/<trace>/, belt/dead-letters/, belt/send/ (as the editor station), belt/deliver/ (202); trials/ and claim-checks/ (a run in the worker, 202; per check resolve/), claim-checks/calibration/ (outboxdesk/README.md)
/api/v2/sites/ the site registry: the sites a person sees (the studio's site switcher) and, for sites.manage_site, registering one, its registry fields and settings, its findings, and sync/, export/ (the write-back) and doctor/ as jobs (sites/README.md)
/api/v2/jobs/ background jobs: a person's and their sites', each with its log (stream/ as server-sent events), artifacts and cancel/ (jobs/README.md)
/api/v2/distribution/ channels/ (connect/, disconnect/, check/, statistics/, ledger-file/), posts/ (the queue: approve/, reject/, publish/ answering 202, record/), ledger/ with statistics, and LinkedIn's oauth/linkedin/ callback (distribution/README.md)
/api/v2/automations/ automations (per automation enable/, disable/, test/, dry-run/, export/, rotate-secret/, and webhook/ — a webhook trigger's endpoint, signed with the automation's secret instead of a session or token), import/, condition/, options/, and runs/ by cursor (automations/README.md)
/api/v2/aieo/ AIEO: score/, audits/ (batch/, summary/, per audit report/ and screenshot/), patterns/ (<name>/apply/), rewrites/, agents/ (run/), citations/queries/ (<id>/check/), citations/checks/, citations/share/, connectors/ (<id>/sync/, <id>/data/), priorities/, context/<site>/, lifecycle/ (aieo/README.md)
/mcp/ MCP, bearer-token authenticated (manage.py agent_token <slug> --name …)

REST takes a session (the studio, signed in through django-allauth's headless API, with its CSRF token), an agent's token (zer0_…, manage.py agent_token) or a person's token (zer0u_…, issued in the studio's account menu or by manage.py user_token, which the VS Code extension sends from the editor's secret storage; one without the write scope only reads). GraphQL takes the same three. | /healthz, /readyz, /version | liveness (touches nothing), readiness (database, cache, Redis — 503 with checks when one is down), the build (name, version, commit, built_at) | | /api/v2/openapi.json, /api/v2/docs/ | the OpenAPI document (committed at schemas/openapi/openapi.json, drift-checked) and its UI where API_DOCS_ENABLED |

Every response carries X-Request-Id (echoed when a client sent one) and X-App-Version; every non-2xx a REST path returns is the envelope in ops/README.md, and GraphQL and MCP carry the same code and request_id in their own error shapes.

Tests

tests/ mirrors the plan's milestones: cms/ (M4; P4: test_tasks.py), api/ (M5, M12; P4: test_session.py, test_pages.py, test_review.py, test_studio.py), importers/ (M6, M7, G8), outbox/ (M8, both planes' contracts), agents/ (M9, M12), suggestions/ (M10), schema/ (M11), graph/ (M13, M17), workflow/ (M14), mcp/ (M15), ops/ (G1; P4: test_server.py), ai/ (G8), books/ (G9), newsroom/ (G15), research/ and ideas/ (G14), outboxdesk/ (ADR 0007), sites/ and jobs/ (G4), distribution/ (G5), automations/ (G16), aieo/ (G7), accounts/ (G10: a person's token). The session database runs sync_agents --publish once, so every test starts from live, eval-passed agents; no test reaches a network or a model provider. Under -n auto each pytest-xdist worker is a session of its own: pytest-django gives it its own test database (a private in-memory SQLite, or test_<name>_gw<N> on Postgres), which it migrates and publishes the agents into before its first test.