// POST /cms/admin/posts/:id/pipeline — run the editorial publish pipeline on a // post (author+, own-only unless admin). Starts the durable workflow and // returns its run id; the UI polls it via workflow::run_status (F-038). import "auth" as auth; let g = auth::guard(ctx, ["admin", "author"]); if !g.ok { return g.response; } let user = g.user; let post_id = ctx.request.params.id; let post = docs::collection("posts").get(post_id); if post == () { return #{ statusCode: 404, body: #{ error: "post not found" } }; } let is_admin = users::has_role(user.id, "admin"); if !is_admin && post.data.author_id != user.id { return #{ statusCode: 403, body: #{ error: "not your post" } }; } // durable DAG; each step reads post_id from its input mapping let run_id = workflow::start("editorial_pipeline", #{ post_id: post_id }); #{ statusCode: 202, body: #{ run_id: run_id, workflow_run_id: run_id } }