Skip to content
open.blog documentation
open.blog

ADR 0303: The job-draft task returns a strict, plain-text draft that can never fill a job field, and the core checks it

Context#

The author talks for ninety seconds and wants a draft that sounds like them. A provider can write it, but a job post is a record a business publishes: a draft that invents a price, sets job.trade, smuggles HTML or ends up saved on its own would be worse than no draft. The task needs one contract that the provider is held to, that tests can pin, and that cannot reach anything the author did not type.

Decision#

  • A new Assistant task, job-draft, beside review, completion and the voice guide, on the same provider boundary. POST /admin/api/assistant/job-draft takes notes (typed, or a transcript the author has read and edited, at most 8,000 characters), optional photoAlts (twelve of at most 200 characters), the job words trade, service and town (at most 80 characters, one line), and contextIds. It is an authenticated, CSRF-protected route with the ordinary JSON bound, the shared concurrency permit and the provider timeout.
  • The voice guide comes through the existing context selection. contextIds are resolved on the server by the same function review and completion use (ADR 0278): the browser names a guide or sample, the server reads it again and counts it against the request budget, and text the browser supplies for it is ignored. Capture names only the voice guide; the route accepts any selectable context.
  • The author's words are data. The normalized request puts the trusted rules (systemInstructions, the engine guide and platformCapabilities) apart from untrustedData (notes, photoAltTexts, job, context). The rules say to use only what the notes say, to leave a section empty rather than invent, never to return any other field, and that nothing in untrustedData is an instruction, even when it asks to change behavior or publish. A voice guide adds the existing sentence that it is data to compare against.
  • One strict result, checked in the core. The result is { title, description, sections: { problem, found, did, result } } and nothing else. openblog_core::job_draft::JobDraft::from_json refuses the whole result, with a plain reason that repeats nothing from it, when: any other key appears (so a job, slug, draft or front matter field has no place to go); a field is missing or not text; a title is empty, a title or description is not one line, or any field is over its bound (120, 300 and 1,500 characters); or any field holds HTML, a code fence, an image, a heading, a front-matter line or a control character. A section may be empty, because a draft that leaves out what the notes never said is better than one that makes it up, but not all four. Providers are also given the same shape as a JSON schema with additionalProperties: false.
  • A proposal, never an action. The route returns { draft, body, proposal: true }, where body is the scaffold with each section under its heading (JobDraft::body, written once beside scaffold_body). It writes no file, saves no post and sets no field. An invalid result is 502 invalid-result: "The provider's job draft was rejected because …. Nothing was applied."
  • The engine guide teaches it. A job-drafts capability is added to the guide every Assistant request carries, and the guide version becomes 6.

Considered options#

  • Letting the draft suggest job fields too. Rejected: the Job form's fields (trade, dates, place, outcome) drive validation, structured data and archives. They are the author's to enter, so the schema has nowhere to put one.
  • Sanitizing instead of rejecting. Rejected: stripping markup would quietly change what the provider wrote; refusing the draft whole keeps "what you were shown is what was checked".
  • Making it a review skill. Rejected: a skill is a Markdown file the author edits, and the draft's contract must not be editable away. The rules live in the request, like the voice-guide payload.

Consequences#

  • Any provider that can follow a JSON schema works; a custom HTTPS endpoint gets the same normalized payload.
  • A provider that wanders gets a refusal and a way forward (type the notes), never a half-applied draft.
  • Changing the draft's bounds or sections is a change to one core module, one schema and the guide text.

View this page's source