orch: require explicit dispatch execution mode

This commit is contained in:
2026-03-20 19:27:30 +08:00
parent 7840b2767f
commit 5859ff219e
43 changed files with 277 additions and 312 deletions
@@ -10,15 +10,15 @@ import (
)
type dispatchOptions struct {
runID string
taskID string
toAgent string
body string
bodyFile string
baseRef string
repoPath string
workspaceRoot string
strictWorktree bool
runID string
taskID string
toAgent string
body string
bodyFile string
executionMode string
baseRef string
repoPath string
workspaceRoot string
}
func newDispatchCmd(root *rootOptions) *cobra.Command {
@@ -28,6 +28,11 @@ func newDispatchCmd(root *rootOptions) *cobra.Command {
Use: "dispatch",
Short: "Dispatch a ready task to a worker through inbox",
RunE: func(cmd *cobra.Command, args []string) error {
normalizedOpts, err := normalizeDispatchOptions(*opts)
if err != nil {
return err
}
body, err := resolveBodyValue(opts.body, opts.bodyFile)
if err != nil {
return err
@@ -41,12 +46,12 @@ func newDispatchCmd(root *rootOptions) *cobra.Command {
defer sqlDB.Close()
result, err := store.NewOrchStore(sqlDB).DispatchTask(ctx, store.DispatchInput{
RunID: opts.runID,
TaskID: opts.taskID,
ToAgent: opts.toAgent,
RunID: normalizedOpts.runID,
TaskID: normalizedOpts.taskID,
ToAgent: normalizedOpts.toAgent,
Body: body,
BaseRef: opts.baseRef,
PrepareWorkspace: newDispatchWorkspacePreparer(cmd, *opts),
BaseRef: normalizedOpts.baseRef,
PrepareWorkspace: newDispatchWorkspacePreparer(cmd, normalizedOpts),
})
if err != nil {
return err
@@ -82,12 +87,13 @@ func newDispatchCmd(root *rootOptions) *cobra.Command {
cmd.Flags().StringVar(&opts.toAgent, "to", "", "Worker agent override")
cmd.Flags().StringVar(&opts.body, "body", "", "Task message body")
cmd.Flags().StringVar(&opts.bodyFile, "body-file", "", "Read task message body from file")
cmd.Flags().StringVar(&opts.executionMode, "execution-mode", "", "Execution mode: analysis or code")
cmd.Flags().StringVar(&opts.baseRef, "base-ref", "", "Optional base ref to record on the attempt")
cmd.Flags().StringVar(&opts.repoPath, "repo-path", "", "Source repository path for worktree dispatch")
cmd.Flags().StringVar(&opts.workspaceRoot, "workspace-root", "", "Workspace root for worktree dispatch")
cmd.Flags().BoolVar(&opts.strictWorktree, "strict-worktree", false, "Require strict worktree setup")
_ = cmd.MarkFlagRequired("run")
_ = cmd.MarkFlagRequired("task")
_ = cmd.MarkFlagRequired("execution-mode")
return cmd
}