Repository navigation
docs(plans): design /goal, a session goal the runtime pursues for hours or days (ENG-982) - #226
Conversation
…rs or days (ADR-0049 revised) Survey how Codex, OpenCode, Pi and fx pursue one objective over time, and design QQ's version without copying any of them: - a session goal that only a client creates; - a runtime goal driver that queues one goal run at a time; - budgets enforced through RunLimits clamped at start; - completion checked by a client-set GoalCheck run; - durable waits and backoff; - pause-on-cancel as a runtime rule; - /goal, qq run --goal and qq goal. ADR-0049 is revised in place, still Proposed. The loop guard is unchanged. Autonomous-core AC7-AC9 move to the new goals plan as G0-G3. ADR-0048's AutoContinue skips goal runs. No code change.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ccc8b47abc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
- Check runs take a workspace-wide exclusion. - Checks are authorized by an exact-command held approval, never by caller flags. - Pause, replace and clear cancel queued goal work and ask running work to cancel. - update_goal is dispatched serially. - The approval wait is clamped to the deadline and its pause takes precedence. - Stale check results are ignored, and an interrupted check pauses instead of re-running. - Goal history rows, a final-run wrap-up, and runs with no committed turn don't count toward the cap. - A user prompt pre-empts an unclaimed goal run. - qq run --goal returns on any non-active state. - Managed ceilings can only be lowered. - G0 and G1 are merged into one goal PR with AC4. - Stale AC7-AC9 ledger rows and ADR section references are fixed.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fb1e510c91
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
ENG-982 / PR #226: address all 12 latest Codex findings with explicit once/for-goal check consent, bounded check deadlines, exact goal CAS, stale outcome fencing, guarded cancellation/resume, historical spend, fresh goal recovery, user-priority checks and final-slot handoff. Synchronize slice gates, valid ledger statuses and protocol/dependency planning. Design only; ADR-0049 stays Proposed. Independent design review approved. Formatting, workspace Clippy, docs-truth, workspace build and full workspace tests with --test-threads=4 passed. Initial unrestricted tests hit five timing-sensitive deadline failures; all 12 deadline tests passed serially. No runtime or wire changes.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Spec
ENG-982, a follow-up to #211 / ENG-978. Design only; no code.
What
/goalisYou give QQ an objective, an optional check command (for example
cargo test -p billing) and a budget (a deadline, a run cap, and optionally tokens and cost). The runtime then works on it by itself across runs, restarts, provider outages, waits on external things, and days, until one of these happens:Any client can see its state, spend, remaining budget and next wake time without reading the transcript.
Research (
docs/design/goal-reference-survey-2026-09-28.md)Only Codex has a real goal feature:
ext/goal,/goal, and idle continuation. It has four weaknesses:The others each have a piece:
finishTurncontinue hook, which its README warns loops forever.Design (ADR-0049, revised in place, still Proposed)
(goal_id, revision)when it is claimed; stale claims are rejected or mergedpending_run_idguard. Every stop that leaves the goal active recovers with a fresh run from committed history and the current goal. ExplicitContinueRunrejects, andAutoContinueskips, goal-snapshot runsRunLimitsis clamped to the goal's remainder when it starts, user prompts included. A shared exact-once finalization step covers every terminal path, including queued/reserved failures, recovery and panic. It charges committed spend to the referenced goal even after clear/replacementaudit_pending. The check command runs as aGoalCheckrun: it holds the session slot and workspace-wide exclusion, can be cancelled, and waits/process share the goal-clamped deadline. The client explicitly authorizes one check start or repeated exact checks for this goal; ordinary approve-once is never widened. Exit 0 at the live active claimed revision meansachieved; a failure feeds its output back to the next run; 3 failures meansblocked. With no check, one audit turn decides. The audit allowance is boundedpaused{needs_user}. An approval held longer than 10 min givespaused{needs_user: approval}. Repeated failures or no progress giveblocked. All counters are in the store, so a restart keeps themSurfaces:
/goal(panel),/goal <objective>(form),/goal pause|resume|clear|edit, and a status line.qq run --goal … [--check CMD]stays in the foreground until the goal ends, with JSONL records and an exit status for each outcome.qq goal set|show|… --sessiondrives a goal held byqq serve.Plan (
docs/plans/goals.md): G0 combines protocol/store, goal in runs,update_goal, check authorization shapes and AC4 (loop guard) in one protocol bump. G1 is dropped into G0. G2 builds the driver; G3 builds checks and owns the full checked-completion gate; G4 builds surfaces; G5 records live evidence. This replaces autonomous-core AC7–AC9. Goal recovery no longer depends on AC5 (ContinueRun). Acceptance is a scripted multi-day run on a simulated clock: 40 goal runs, 2 process kills, a 26-hour gap, a 6-hour outage, waits and interleaved prompts, reachingachievedwith no call re-executed and never two runs queued.Review before opening
Given the review load on #211, I first had an independent reviewer check the design against source. It found 12 problems, and all are fixed in this PR. Among them:
shell.rs:23) and it needs a claimed run to hold approvals. The check is now its own run kind.ClaimedRun(settlement.rs:1061), so the proposed shared goal-finalization step reads the persisted run identity/accounting, including recovery and queued/reserved terminal paths.commands.rs:598), so they are now clamped at start.AutoContinuewould have double-scheduled goal runs.The list is in the ledger.
Also changed
ContinueRunrejects andAutoContinueskips runs that have a goal snapshot; recovery uses fresh goal runs without weakening latest-prompt admission.autonomous-core.md: AC7–AC9 now point togoals.md;ContinueRunno longer admits completed runs; the goal counters are gone from the reset-scope table.docs/README.md,plans/README.md,progress/README.md,adr/README.mdand theroot.mdrow for 0049.Verification (latest correction
c4f42c3)cargo test -p qq docs_truth: 5 passed in the isolated worktree.cargo fmt --all -- --check: passed.cargo clippy --workspace --all-targets --all-features -- -D warnings: passed.cargo test --workspace: five existing deadline-test failures. All 12 deadline tests passed with--test-threads=1; fullcargo test --workspace -- --test-threads=4then passed. The initial failures are disclosed, not waived or fixed by unrelated Rust changes.cargo build --workspace: passed.git diff --check: passed.Latest Codex findings
All 12 findings on
fb1e510were valid and are addressed inc4f42c3: scoped check consent, hard deadlines, stale status/wait/result fencing, cancellation ownership/early-resume rejection, prompt final-slot handoff, fresh recovery, exact goal CAS, explicit terminal lifecycle, G2/G3 gate ordering, valid ledger states, prompt-priority queued checks, and archived accounting. Each is mapped to future G0/G2/G3 acceptance; this PR remains design-only. The ledger and decisions-needed row 11 record the rationale.Decisions needed
goals.md: the 24 h default deadline and a separate goal-run pool.decisions-needed.mdrow 11 (fresh recovery, explicit check scopes, achieved replacement/stopped-goal resume).