Shift work: draft
shiftwork_draftTurn settled tickets into a validated shift-work job checkpoint and one brief per ticket before clock-in, dry-run by default or write files.
Instructions
Shift-work draft: turn tickets into a new job — a checkpoint that validates against the checkpoint schema, plus one brief file per ticket — so step 1 of the shift-work loop is not typed by hand. Call it once, when a job's tickets are settled and before the first shiftwork_clock_in; it never edits a job in progress (that is the planner's edit, or shiftwork_clock_out's follow_ups), and work_plan is the read-only answer when all you want is the batches. Every ticket needs a non-empty id, title, role, verify, data_shape (the types, fields, files or messages the unit produces or consumes — a ticket without one is not ready to execute) and brief; the first missing one is refused by name. The graph is work_plan's: its refusals come back verbatim, batches and width are its answer, and cursor is the first ready unit, the one shiftwork_clock_out would pick. With job.roles declared, a ticket role it does not name is refused. Each ticket becomes a todo unit with brief_path <briefs_dir>/.md; any other ticket key (touches, reviews, irreversible, ...) is copied onto the unit, and the composed document must pass the checkpoint schema and shiftwork_plan's graph checks, or the schema's sentence is the refusal. write is false by default: the document and every brief's text come back and nothing is touched. With write: true the briefs and then the checkpoint are written by temp file + rename under .lock; an existing checkpoint, or an existing brief with other bytes, is refused before anything is written, and a failure part-way names what landed in written. It never runs git, never runs verify and never reads the working tree: repo is taken as given. Refusals are {"result": "error", "reason"}, never exceptions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| job | Yes | The checkpoint's `job` object, copied as given: id, goal, done_definition, constraints, and optional roles, budget or agreements. | |
| repo | Yes | state.repo as given: {branch, head_sha, dirty}. Never read from git. | |
| write | No | true writes the briefs and the checkpoint; false or absent is a dry run that touches nothing. | |
| handoff | No | Optional do_not, open_questions and notes for the checkpoint's handoff; next_action is always written as `Read <cursor brief> and clock in <cursor>.` | |
| tickets | Yes | One per unit, in plan order. Keys other than the six required ones, depends_on and priority are copied onto the unit and judged by the checkpoint schema. | |
| artifacts | No | {path, role} entries (spec, plan) appended to state.artifacts after one brief entry per unit. | |
| briefs_dir | No | Directory of the brief files, also the prefix of every brief_path; default .shiftwork/briefs. | |
| checkpoint | No | Where the checkpoint is written with write: true, absolute or relative to the server's working directory; default .shiftwork/checkpoint.json. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| width | No | work_plan's width: the widest batch. | |
| briefs | No | One per unit: its id, its brief_path, and `bytes`, the file's full UTF-8 text. | |
| cursor | No | plan.cursor: the first unit of the first batch. | |
| reason | No | The refusal sentence, when result is `error`. | |
| result | Yes | `draft` on success; `error` with `reason` for the first refusal. | |
| batches | No | work_plan's batches over the tickets, priorities included. | |
| written | No | Paths written by this call, briefs first and the checkpoint last; [] on a dry run, and on a write-side refusal the paths that landed before it. | |
| checkpoint | No | The composed checkpoint document, valid against assets/schemas/shiftwork-checkpoint.json. |