Skip to content

Implement Goals as a thin native /goal task mode #2071

Description

@integry

Context

This supersedes the unreleased goal control-plane/runtime/UI implementations in #2003-#2015 and PRs #2020, #2059, #2065, #2067, and #2070.

A goal is not a ProPR-authored plan. It is one existing ProPR coding-agent task whose first agent input is the native slash command /goal <objective> (or the provider's documented non-interactive equivalent). The coding agent owns planning, decomposition, parallel subagents, issue/PR structure, status answers, and completion.

Implement this as a thin execution mode over ProPR's existing task machinery. Do not build a second orchestration system.

Reuse these existing primitives

Use and extend the current:

  • AgentRegistry and each provider's executeTask container path;
  • worktree allocation, branch handling, credentials, image/config mounts, container naming, callbacks, abort fencing, and queue de-duplication;
  • worker task state/history metadata for task, session/conversation, container, worktree, model, and lifecycle state;
  • Redis/container streaming, taskWatcher, conversation parsers, /api/task/:id/live-details, execution logs, todos, and token usage;
  • existing stop/cancel and follow-up mechanisms;
  • existing realtime task delivery and polling fallback;
  • existing LLM metrics and task duration/history.

Do not add a goal-specific supervisor, lease system, WAL/event/output database, JSON/JSONL authority, socket protocol, container manager, provider-effect ledger, planner, node graph, dependency scheduler, merge scheduler, or synthetic checklist.

Minimal durable model

Add only a small owner-scoped goal record (or an equivalent first-class task discriminator) that references the existing task execution and stores fields not already authoritative elsewhere:

  • goal ID, owner, repository, objective, branch/worktree identity;
  • immutable selected agent and current/requested model;
  • optional max-parallel-tasks and Ultrafix preferences passed as policy to the coding agent;
  • desired host state (running, paused, cancelled) and final result state;
  • current existing task ID plus provider session/conversation identity;
  • passively discovered final PR/artifact references.

Existing task history/output/metrics remain authoritative. Do not copy them into goal-specific tables.

Native execution contract

  • Add a goal execution mode to the existing agent task options/runner.
  • Initial stdin/input is the exact native goal command with the user's objective. Do not wrap it in ProPR implementation/planning prompts.
  • Goal mode preserves provider session state. It must not use current one-shot flags such as Claude --no-session-persistence or Codex --ephemeral.
  • On retry, host restart, or container loss, enqueue the same goal task against the same worktree and resume the persisted provider session/conversation. Never start a second goal silently.
  • Claude, Codex, and Antigravity use their documented native goal/session-resume capabilities in the existing agent containers. Capability-probe the pinned binary and expose goalCapable: false if a provider/version does not actually support native /goal; do not emulate it with a ProPR loop.
  • Persist session/conversation identity through the existing early-session callback before claiming crash recovery.
  • Pause stops further native continuation at a safe supported boundary while retaining the session/worktree. Resume re-enqueues the same session. Cancel is terminal and distinct.
  • Corrective and canned “what's done?” / “what's left?” messages are ordinary inputs to the same provider session and their replies are ordinary task output.
  • A supported model change becomes the requested model for the next safe continuation/resume and records the effective model reported by the provider.
  • Parallelism and Ultrafix are text/structured policy supplied once to the coding agent; ProPR does not schedule the resulting work.

API and UI

Add a dedicated Goals navigation/list/create/detail surface, but compose it from existing task APIs and components wherever possible.

  • Create selects repository, agent, model, objective, optional parallelism, and Ultrafix preference, then starts exactly one native goal task.
  • List/detail joins minimal goal metadata with existing task history and live-details output.
  • Terminal output, provider-native todos/checklist, current task, and token usage come directly from existing task parsing.
  • Reuse the existing realtime task stream and polling fallback. Do not define a second goal event/replay/socket protocol.
  • Controls expose pause/resume/cancel, supported model changes, canned status messages, and free-form corrections.
  • Show elapsed/active/paused time from goal/task history and passively associated issues/PRs; do not manufacture an issue hierarchy.
  • The final PR is the coding agent's draft epic PR (or its single PR for a small goal), recorded for human review and never auto-merged by goal mode.
  • Enforce the same owner/repository authorization used by tasks on every read and mutation.

Recovery

On worker/daemon startup, find nonterminal goal records whose existing task/container is no longer live and re-enqueue a fenced resume using the saved provider session and worktree. Reuse current task/container liveness checks and duplicate-execution protection. Recovery must be idempotent and must not create a new worktree, branch, or provider goal.

Validation

  • Unit/contract tests prove goal mode changes provider CLI arguments/input while the normal one-shot path is unchanged.
  • Tests prove no ephemeral/no-persistence flags in goal mode and exact session resume for each supported provider.
  • A worker/container crash test proves re-enqueue resumes the same goal/task/worktree/session once.
  • Existing live-details tests prove terminal output, native todos, current task, and tokens render without a new event store.
  • UI tests cover create/list/detail, pause/resume/cancel, model request/effective state, corrective/canned input, provider capability gating, ownership, and reconnect.
  • Repository validation remains green.

Delivery

This PR targets 2002-epic-long-running-goals. Keep it reviewable and delete/reuse existing abstractions instead of importing code from the superseded goal branches. The epic branch will later produce the final draft PR to main.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions