ADR 0313: Services are edited in Admin through the document routes with a screen of their own, scaffolded as drafts from the command line
- Status: Accepted
- Date: 2026-10-29
- Parent story: #483
- Task: #511
- Parent epic: #473
- Builds on: ADR 0311, ADR 0312, ADR 0307
Context#
Services are Markdown files, so an owner could write them by hand, but the people this epic is for work from a phone. The list of questions is the hard part to type: a block list of mappings with indentation. Admin already edits posts, pages and series through one set of document routes (list, read, create, save with a revision, delete to the trash, preview), each behind a session, CSRF and size bounds. Services must not get a second write path.
Decision#
servicesis a fourth document kind on the existing routes.GET /admin/api/documents?kind=services,GET/PUT/DELETE /admin/api/document?path=services/<id>.mdandPOST /admin/api/documentwithkind: "services"are the same handlers, with the same authentication, CSRF, 2 MiB document bound, revision check (a stale write is a 409) and trash. Nothing new is added to the route table. A new service's file isservices/<id>.md, named from itsid(a service needs no title or slug), and anidthat is not a valid service id refuses the create.- A save is checked by the build. The route composes the file, loads the whole site with it and returns
the build's own sentences for the edited file as
problems(422), so a rule can never pass in Admin and fail in the build. Nothing is written when the file is refused. - The flattened FAQ keys are the only dotted keys besides
job.*. The field-name guard acceptsfaq.<number>.<name>(a number of up to three digits, one name, nothing deeper) and nothing else; a key likefaq.x.questionorfaq.1.question.extrais refused. The editor sendsfaq.1.question,faq.1.answerand so on, renumbered from 1, so a removed question leaves no stale key behind and the front matter writer emits them back as the block list ADR 0311 defines. - A screen of its own, built like Business facts.
#/serviceslists the services;#/services/newand#/services/edit/<path>edit one. It is a module (web/admin/services.js) with the pure rules at the top, tested without a page, and one column from 320px with every control at least 44px tall and named. It has fields for the name, the id (set from the name for a new service, read-only afterwards because it names the file and the page address), the summary, a repeating list of included items and a repeating list of questions (each with Up, Down and Remove, named by their position, and focus placed in a new row), the price band as a select of the jobs' words, the timeline, the page text and a draft box. Keys the form does not own are sent back as they were. Problems are said beside the field, and the first is focused. - A draft service.
draft: truekeeps a service off the site: it is not built and not counted among the known service ids a job is checked against, and while it is unfinished its problems are only warnings (service not ready to publish: ...). This lets a half-written service be saved from a phone, and lets the scaffold below write the file without stopping a build, the way a new job does (ADR 0287). Admin's preview and any load that includes drafts see it. - Jobs are offered the real ids. The job form's service suggestions (
meta.job.services) now include the ids of the site's published services. openblog new "Name" --profile servicewritescontent/services/<id>.md:version: 1,id(from--id, or the name as a slug),name, an emptysummary,priceBandwhen--price-bandis given, anddraft: true, then a line of body text. The id and the band are checked with the build's own functions and nothing is written when one is refused or the file exists.--series,--tagsand the job options are refused.openblog checklists what is still missing.- The durable workspace allow-list includes
services/besideposts/,pages/andseries/, so a hosted Admin can read and write them.
Consequences#
- A service's own file keeps unknown top-level keys; keys inside one question other than
questionandanswerare not kept by the editor, which renumbers entries. - A
status: draftkey (which other documents accept) also holds a service back, but the draft box only readsdraft.