Writing an orchestrator adapter
Read the manifest in the main checkout. Each task names its branch, parent, dependencies, spec sections and gate. Start a task when its prerequisites and gate rules permit it. Use the package entry point @prddd/contract/js from a JavaScript runner to locate the shared workspace and validate the manifest.
Locate the main checkout’s state with
cairnDirand decode its manifest withparseManifest. A linked worktree shares that state with the main checkout.Append state changes with
appendEvent(path, event). Each event carries a task ID, timestamp and status. Record the actual model and reasoning when known, and onrunningthe concrete catalog ID the model ran as inmodelId; routing from history counts only attempts that carry one. Include a reason on failure. The helper validates the event and appends one JSON line.Attach the task, implemented sections and session to commits using
formatTrailersortrailerArgs. Store redacted session evidence under the same session ID so a commit can lead a reviewer back to the work.Report gated work as waiting for a human. Let the reviewer run the approval command. Record landing only after the commits reach the target branch.
Anchor persistent findings with
prd noteand generate a location withprd link. A link can identify the section, task, file and line a reviewer should inspect.
Check the result with prd status --json. Reconcile retries with the recorded events and branches before assigning the same work again.