Skip to content

fix(chat): bind Resume to the displayed goal - #207948

Draft
freeqaz-openai wants to merge 2 commits into
mainfrom
fix/guard-stale-chat-goal-resume
Draft

freeqaz-openai wants to merge 2 commits into
mainfrom
fix/guard-stale-chat-goal-resume

Conversation

@freeqaz-openai

@freeqaz-openai freeqaz-openai commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A delayed Resume can start a different task. A second client pauses and edits the objective while the first client's request is in flight. The Goal ID stays the same, so checking the ID alone lets the delayed request start the edited Goal.

User Impact

Control UI requires a snapshot of the displayed Goal for every fresh Resume. If the objective changes, refresh the chat, review the edit, and choose Resume again. This also works with Codex. It previously reported a definite refusal as a retryable outage. A request that already committed still returns its original receipt.

Why This Change Was Made

Admission checks a digest of the displayed Goal before launching a runtime. Otherwise, a rejected Codex attempt can pause an edited, active Goal. The writer repeats the comparison when it commits the continuation. The browser needn't save the objective text for recovery. Its local check distinguishes an active Goal from a newly displayed budget limit. The digest treats the budget projection as active because only the writer owns token accounting. It includes the timestamp, objective, status, budget and status note.

The runtime acknowledgment retains the typed persistence error if dispatch settles without committing. The same run-specific refusal prevents the failure handler from pausing the edited Goal. An unknown SQLite outcome or unreadable receipt remains uncertain. The UI and Gateway ship together. The capability flag and unguarded UI fallback were removed. Previously saved retries retain their original payload. Other clients can send the optional precondition.

Evidence

I compared disposable packaged Gateways with a real Codex CLI 0.172.0, SQLite, two authenticated connections and scripted inference. All builds included the same three separate worker and thread recovery changes. I compared the base, the initial patch, an intermediate fix and this revision. After a Gateway crash, I confirmed the original worker's reply and prepared Resume. A second client edited the same Goal before I sent the request.

  • Without this PR, the delayed request started the edited Goal. At 53d813af the request failed with retryable UNAVAILABLE and no reason.
  • With only the runtime acknowledgment fixed, the stale attempt returned the correct reason but paused an edited active Goal. That prompted the additional admission check.
  • At d2956248 both the active edit and the pause-then-edit returned INVALID_REQUEST, GOAL_OPERATION_REJECTED, goal-rebound. Each kept its status, revised objective and original last-run ID. In each four-second check there was no new visible user input, lifecycle event or inference.
  • A fresh Resume continued on the original native parent thread. Its get_goal read the revised objective and it finished in 1.55 seconds. Retrying that confirmed operation returned the same run ID. The four-second replay check observed no new run start or inference.

The combined tree was 425af3fe0757463b41cb10389f916d17c0798a53. The other changes were #193024, #206821 and #207617. This trial required explicit Resume after the crash.

I also tested an edit after admission. A temporary synchronization point held one request just before dispatch while the second client edited the active Goal. This test used a separate disposable copy of the packaged handler and checked both its original and restored hashes. The writer rejected Resume with goal-rebound, and the persisted Goal stayed active and unchanged. There was no inference or new visible user input. A fresh, confirmed Resume read the edit and completed, and the subsequent replay made no model call. The timing hook is outside the PR.

On the standalone change I ran the following with one worker. Durations include cold setup.

  • pnpm --dir ui test src/pages/chat/chat-goals.test.ts src/pages/chat/chat-view-goals.test.ts --maxWorkers=1 passed 40/40 in 17.76 s.
  • pnpm test src/gateway/server.chat-goal.test.ts --maxWorkers=1 -t 'stale|same completed Goal|refusal|definite|rejects a prepared retry' passed 6 selected cases in 203.05 s. The filter excluded 67 cases. The checks include an equal-timestamp edit, Codex approval and replay.
  • pnpm test src/gateway/session-lifecycle-state.worker.test.ts src/gateway/session-lifecycle-state.test.ts src/gateway/session-lifecycle-persistence-owner.test.ts --maxWorkers=1 passed 61/61 in 66.66 s.
  • Type-aware lint on the changed TypeScript and git diff --check passed. Session projection and storage suites passed 44/44 on the earlier head. Removing the UI status comparison made the budget-limit regression fail.

An edit after admission can still produce a failed-run record and a chat error. The edited Goal retains its status. The guard cannot detect a return to identical compared state or freeze token usage in flight. Text commands are unchanged. There is no new storage, automatic restart, permission or protocol version.

@clawsweeper

clawsweeper Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime size: M labels Nov 29, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. impact:session-state Session, memory, transcript, context, or agent state can drift or corrupt. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 29, 2026
@clawsweeper

clawsweeper Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: passed.

What this changes

This PR binds fresh Control UI Resume requests to the displayed Goal state and preserves definite rejection outcomes.

Example: One client prepares Resume for “Original checklist” while another edits the same Goal to “Edited checklist”.

  • Before: The delayed Resume can start “Edited checklist” without the first client reviewing it.
  • After: The Gateway rejects the stale request with goal-rebound and preserves the edited Goal.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-supported repair with distinct regression coverage; independently inspectable runtime evidence remains limited, and the optional request field preserves existing saved-request validation and receipt formats.
Proof confidence 🦐 gold shrimp (3/6) This PR is exempt from contributor proof requirements; its detailed packaged-Gateway report covers stale rejection, fresh Resume and replay with SQLite and real Codex transport, but uses scripted inference and a combined recovery tree rather than an attached standalone trace.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Clicking Resume can start an objective another client edited after the user reviewed it.
Reason: The repair preserves the existing promise that Goal controls target the displayed task, and the host identifies the direction as maintainer-authored.

Merge readiness

✅ Ready for maintainer review

This PR repairs a current stale-Resume bug and resolves the previous review finding. No blocking defect was found; it remains a draft.

Reviewed head: d295624867debed7e1ab81e2d0a19b2f23f6f476

Before merge

None.

Findings

None.

Agent review details

How this fits together

Control UI sends the displayed Goal digest through the Goal RPC to existing admission and transactional writers, which return either a continuation receipt or a rejection.

flowchart TD
  A[Displayed Goal] --> B[Resume request and digest]
  B --> C[Gateway admission]
  C --> D[Transactional Goal writer]
  D --> E[Continuation and receipt]
  C --> F[Stale request rejection]
  D --> F
Loading

Technical review

Best possible solution:

Keep the displayed-state precondition in the existing admission and transactional Goal owners while preserving committed-request replay.

Do we have a high-confidence way to reproduce the issue?

Current-main source permits a delayed Resume after a same-ID objective edit, and the PR reports that exact two-client failure; this review executed no target code.

Is this the best way to solve the issue?

The patch repairs the existing Goal mutation boundary, handles equal-timestamp edits, and preserves receipt replay without adding another state owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 7a715e060ccf.

Provenance checked

  • Displayed Goal controls keeps the original intent (5e245aa: Offer explicit Resume for idle active Goals while checking displayed identity, status and competing work.)
  • Transactional Goal operations keeps the original intent (0474704: Use existing chat admission, atomic Goal/input commits and durable receipts for graphical Goal controls.)
  • Runtime Goal acknowledgement keeps the original intent (eec3594: Keep runtime Goal input pending until admission and acknowledge only its committed operation.)
  • Failure lifecycle projection changes intended behavior with a stated reason (5b1d81e: Reduce lifecycle updates against the writer's current session state while preserving durable failure ordering; the PR explains why a refused continuation must not pause an edited Goal.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Previous finding resolved: The capability-dependent fallback is removed, and every fresh UI Resume requires a displayed Goal and computes its digest; previously saved operations retain their original payload. (ui/src/pages/chat/chat-goals.ts:499, d295624867de)
  • Current main still needs the repair: Current main checks Goal identity and optional status in the UI but sends no displayed-state digest, while its operation writer checks Goal identity alone. (ui/src/pages/chat/chat-goals.ts:496, 7a715e060ccf)
  • Shared transactional precondition: The existing Goal policy compares the digest against the current Goal before applying its transition; runtime admission also checks it before launch. (src/config/sessions/goals-operation-policy.ts:61, d295624867de)
  • Rejection and lifecycle handling: Runtime acknowledgement retains definite Goal persistence errors, and a run-specific refusal fact prevents failed stale Resume from pausing the edited Goal. (src/gateway/server-methods/chat-send-goal-ack.ts:19, d295624867de)
  • Reported production behavior: The full PR body reports packaged-Gateway trials with two authenticated clients, SQLite and Codex 0.172.0: stale requests were rejected before and after admission, edited Goals retained their status, and fresh Resume plus replay behaved correctly; inference was scripted and the tree included three separate recovery PRs. (d295624867de)
  • Native runtime contract inspected: The PR explicitly claims Codex behavior, so the sibling runtime contract was inspected: turn_start_inner loads the selected thread and processes input; OpenClaw's harness commits approved input before invoking the plugin. (codex-rs/app-server/src/request_processors/turn_processor.rs:578, 3d86e43b075a)

Likely related people:

  • Free Wortley: Raw commit 5e245aa adds ui/src/pages/chat/chat-goals.ts:302 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5e245aa0fe68; files: ui/src/pages/chat/chat-goals.ts)
  • Peter Steinberger: Raw commit 0474704 adds src/config/sessions/goals-transitions.ts:63 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 047470456ff2; files: src/config/sessions/goals-transitions.ts)
  • Galin Iliev: Raw commit eec3594 adds src/gateway/server-methods/chat-send-goal-ack.ts:17 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: eec35949bda1; files: src/gateway/server-methods/chat-send-goal-ack.ts)

PR surface

Source +125, Tests +168, Docs +12. Total +305 across 25 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 19 222 97 +125
Tests 5 233 65 +168
Docs 1 12 0 +12
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 25 467 162 +305

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Protocol addition 1 optional expectedGoalStateHash parameter Adds a request precondition without a configuration option or protocol-version bump.

Labels

Label changes:

No label changes.

Label justifications:

  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-29T04:16:58.658Z sha 53d813a :: needs changes before merge. :: [P2] [P2] Guard fresh UI Resume requests without a version fallback

Reviewed November 29, 2026, 12:29 AM ET / 05:29 UTC (Revision 2).

@freeqaz-openai

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 29, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime impact:session-state Session, memory, transcript, context, or agent state can drift or corrupt. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant