Skip to content

fix(tasks): keep chat status reads responsive - #149738

Merged
steipete merged 5 commits into
mainfrom
codex/async-chat-task-status-stack-20260916
Sep 20, 2026
Merged

steipete merged 5 commits into
mainfrom
codex/async-chat-task-status-stack-20260916

Conversation

@steipete

@steipete steipete commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes chat /tasks and task details in /status blocking other Gateway work while the task database is busy.

User Impact

Task status stays responsive during database contention and includes task updates accepted before the read. Existing text, session visibility, agent fallback, and status overrides are preserved. No configuration or migration is required for this feature.

Why This Change Was Made

Both callers use the existing asynchronous task registry read owner, including its fixed accepted-write fence and bounded projection preparation. Session and strict agent selection share that prepared read; callers validate currentness immediately before formatting. The unused synchronous agent path is removed. Detached task execution retains its required synchronous session accessor, and current main retains ownership of identifier normalization and migration.

The existing lineage fixture joins its already-created accepted-event fence before checking for leaked Gateway work. Paired original-order controls reproduced the premature one-second leak check and verified the ordering repair without changing assertions or deadlines.

Evidence

Candidate: 324531fa81952a6146da6de75ec99bde02551364, incorporating canonical main d5b6e687ca30931c5b6a5e82b1ffbcb1d7162ba3.

  • Fresh independent Codex review found no actionable P0–P2 findings. Fresh core/state-test typechecks, formatting, and diff checks pass. Previously completed scoped type/lint/ratchet/import checks remain attributed to their unchanged inputs.
  • 155 focused source cases passed in the prepared identifier-owner composition. Its feature, task-owner, and identifier-fixture bytes match this canonical adoption, so that proof is reused. The inherited fixture import correction is now supplied by main and has no PR delta. Earlier 330-case and 58-case integration receipts remain separately attributed to their original compositions.
  • Maintained pnpm build sourcePerformance passes on Node 24.21.0 in 51.3 seconds, including final metadata and cleanup. This is the runtime build profile, not a fresh declaration/UI build.
  • Three fresh ordinary compiled processes pass on this exact candidate: cold registered /tasks, contended registered /tasks, and contended buildStatusText. Both /tasks cases record zero calls to six parent SQLite methods through canonical cleanup. Timers fire at 10.54 ms and 10.65 ms while the coordinator remains held and rendering is pending. Replies and durable readback retain accepted completion and tool count 1.
  • All three processes exit naturally. The 62 bound source/installation files and complete 13,204-entry dist inventory match before and after. Status rendering retains 15 schema/config reads and five native-retirement calls; no whole-status SQL-zero claim is made.

One-worker costs (pnpm test <file> --maxWorkers=1), measured on the byte-identical prepared sources:

Test file Local wall Reported test time
task-status.worker.test.ts 43.85 s 5.62 s
task-registry-agent-events.lineage.test.ts 25.91 s 10.80 s
task-registry-query.test.ts 20.69 s 0.41 s
status-text.test.ts 34.72 s 5.79 s
commands-status.test.ts 39.47 s 17.15 s

The worker regression measures real event-loop responsiveness while an actual SQLite coordinator is held; this requires the physical worker and timer. Transformation accounts for much of the wall time. CI per-file timing extraction remains unavailable after GitHub quota exhaustion; no zero-cost value is inferred.

Compiled proof uses the registered handler chain with prepared authorized context and the normal status-text entrypoint. It excludes inbound transport/authentication, the full /status wrapper, real providers, and an operator Gateway. Constructors, close methods themselves, and worker-realm SQL are outside the six-method meter. Linked dependency payloads are not exhaustively hashed; installation manifests are bound.

The prior head's CI run 35532890794 failed a shared changed-lanes Stylelint expectation. Its canonical correction landed in #153982. The identifier-fixture import found during the carry landed canonically in #153988 (1c2bdf3e26532e71ae3fbb189b5bc58671f288f6). Both corrections are now incorporated from main; no duplicate fixture fix remains. Exact-head CI run 35538580296 completed successfully for 324531fa81952a6146da6de75ec99bde02551364: all 163 jobs completed with zero failures.

The lineage fixture now passes the required repetition campaign on exact candidate 324531fa81952a6146da6de75ec99bde02551364: 20 whole-file standalone runs (16 cases each) and three original Status eight-file shards (216 cases each), in the order original shard, 20 standalone runs, then the remaining two shards. All 968 case executions pass, including 368 lineage executions. These are repeated measurements, not additional unique coverage. No test failed or was retried; two pre-test harness/runtime preflight failures are retained and excluded. Every invocation verifies source identity, recorded file order, and observed child completion. The 62 bound source/installation files, complete 13,204-entry dist inventory, recorded Node 24.21.0 executable, and original build log match before and after; no rebuild or separate compiled three-scenario rerun occurred.

For these exact-candidate repetitions, standalone wrapper wall time is 20.146 s median / 33.082 s maximum; the reported per-case time sum is 9.743 s median / 14.115 s maximum. Original-shard wrapper wall time is 75.275 s median / 151.915 s maximum; the lineage file's reported per-case time sum within those shards is 8.829 s median / 11.119 s maximum. All shard files have separately retained per-case costs. Case-time sums are rounded reporter measurements, not per-file wall time or compiler/import time. CI per-file wall/timing extraction remains unavailable.

@clawsweeper

clawsweeper Bot commented Sep 16, 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. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: M maintainer Maintainer-authored PR labels Sep 16, 2026
@steipete
steipete marked this pull request as ready for review September 16, 2026 05:25
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 20, 2026, 7:34 PM ET / 23:34 UTC (Revision 14).

ClawSweeper review

What this changes

Moves chat task-status reads onto the existing asynchronous task reader so database contention does not block other Gateway work, while preserving task visibility and formatting.

Merge readiness

✅ Ready for maintainer review

Keep open as a useful, review-ready fix: current main still performs synchronous chat task reads. No actionable patch defects remain, and the updated evidence addresses the previous test-cost follow-up.

Priority: P2
Reviewed head: 324531fa81952a6146da6de75ec99bde02551364

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, maintainable repair with strong scoped runtime evidence, successful exact-head CI, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Recorded exact-candidate compiled runs exercise the registered /tasks chain and status-text entrypoint against actual SQLite contention, showing timer progress before release and correct accepted-update readback afterward; the narrower entrypoint coverage is appropriate for this internal responsiveness repair.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Recorded exact-candidate compiled runs exercise the registered /tasks chain and status-text entrypoint against actual SQLite contention, showing timer progress before release and correct accepted-update readback afterward; the narrower entrypoint coverage is appropriate for this internal responsiveness repair.
Evidence reviewed 8 items Pinned change ownership: Reviewed the introduced delta from d5b6e68 to the exact original head. The supplied stale test merge was not used to infer removal of current-main behavior. The checkout remained clean.
Still necessary on current main: Current main’s task command still builds snapshots through synchronous session and agent accessors. The related artifact and pagination work does not replace this chat-command change.
Latest release retains synchronous reads: The v2026.9.5 source also uses synchronous task-status accessors; this change is not already present in the supplied latest release.
Findings None None.
Security None None.

How this fits together

OpenClaw’s task registry combines persisted task records with accepted runtime updates. Chat commands select session-visible tasks or agent-level counts from that registry and format them into replies.

flowchart TD
  A[Chat tasks or status request] --> B[Existing command authorization]
  B --> C[Asynchronous task reader]
  D[Accepted task updates] --> C
  E[SQLite worker and task projection] --> C
  C --> F[Session selection or agent counts]
  F --> G[Validate current reader]
  G --> H[Formatted chat reply]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +45, Tests +241, Docs +6. Total +292 across 17 files.

View PR surface stats
Area Files Added Removed Net
Source 7 119 74 +45
Tests 9 307 66 +241
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 17 432 140 +292

Review metrics

Metric Value Why it matters
Production versus test growth Production +45 lines; tests and test support +240 lines net Production growth adds selectors to the existing reader and removes the obsolete synchronous agent path; tests cover contention, selection, and override behavior.

Technical review

Best possible solution:

Keep chat task reads on the canonical asynchronous reader, with unchanged visibility rules, accepted-write ordering, and synchronous formatting after currentness validation.

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

Yes: holding SQLite custody while accepted task events precede a chat status read exercises the synchronous path still present on main. This review verified the source path and supplied runtime observations without executing tests.

Is this the best way to solve the issue?

Yes: extending the existing prepared reader is a focused repair that preserves selection and display semantics without introducing another storage owner or migration.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 21f3d71a09d4.

Labels

Label justifications:

  • P2: Repairs Gateway responsiveness during task-database contention without adding configuration or changing chat output contracts.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): Recorded exact-candidate compiled runs exercise the registered /tasks chain and status-text entrypoint against actual SQLite contention, showing timer progress before release and correct accepted-update readback afterward; the narrower entrypoint coverage is appropriate for this internal responsiveness repair.
  • proof: sufficient: Contributor real behavior proof is sufficient. Recorded exact-candidate compiled runs exercise the registered /tasks chain and status-text entrypoint against actual SQLite contention, showing timer progress before release and correct accepted-update readback afterward; the narrower entrypoint coverage is appropriate for this internal responsiveness repair.

Evidence

What I checked:

  • Pinned change ownership: Reviewed the introduced delta from d5b6e68 to the exact original head. The supplied stale test merge was not used to infer removal of current-main behavior. The checkout remained clean. (324531fa8195)
  • Still necessary on current main: Current main’s task command still builds snapshots through synchronous session and agent accessors. The related artifact and pagination work does not replace this chat-command change. (src/auto-reply/reply/commands-tasks.ts:81, 21f3d71a09d4)
  • Latest release retains synchronous reads: The v2026.9.5 source also uses synchronous task-status accessors; this change is not already present in the supplied latest release. (src/auto-reply/reply/commands-tasks.ts:81, ec9c1a13db89)
  • One prepared reader preserves selection: Session details and fallback counts share the existing accepted-write fence and bounded projection preparation. Both callers validate currentness before task formatting. The session predicate is moved unchanged, and detached execution retains its synchronous session accessor. (src/tasks/task-status-access.ts:38, 324531fa8195)
  • Recorded production-path proof: The captured body, sourceRevision 2b7efc94d1b75466deb116351ae30738c5b021a4acf12205dcd1ec668db458f8, records three compiled-process runs on the exact candidate: cold registered /tasks, contended registered /tasks, and contended buildStatusText. Timers progressed at 10.54 ms and 10.65 ms while database custody remained held; replies and durable readback retained completion and tool count 1. The stated boundary excludes inbound authentication, providers, and the full /status wrapper. These observations were assessed without executing target code. (324531fa8195)
  • Previous follow-up addressed: The body now gives one-worker wall and test times for all five added or materially changed test files, explains the real-worker contention test’s cost, and discloses unavailable CI per-file timing. It also records 20 standalone lineage runs and three original-order shards, totaling 968 successful case executions. The lineage patch joins the existing accepted-event fence before the unchanged leak check. (src/tasks/task-registry-agent-events.lineage.test.ts:371, 324531fa8195)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (13 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-16T14:44:49.731Z sha f583e03 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-16T15:53:59.787Z sha f583e03 :: needs changes before merge. :: none
  • reviewed 2026-09-16T17:11:49.533Z sha 91a5b1d :: needs maintainer review before merge. :: none
  • reviewed 2026-09-20T10:32:53.037Z sha 83b558b :: needs maintainer review before merge. :: none
  • reviewed 2026-09-20T10:57:53.908Z sha 83b558b :: needs maintainer review before merge. :: none
  • reviewed 2026-09-20T19:54:01.148Z sha 3222855 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-20T20:41:00.655Z sha 3222855 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-20T21:37:45.212Z sha 324531f :: needs changes before merge. :: none

@steipete
steipete marked this pull request as draft September 16, 2026 08:49
@steipete
steipete marked this pull request as ready for review September 16, 2026 10:05
@steipete
steipete marked this pull request as draft September 16, 2026 11:40
@steipete
steipete marked this pull request as ready for review September 16, 2026 14:38
@clawsweeper clawsweeper Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 16, 2026
@steipete
steipete marked this pull request as draft September 16, 2026 15:47
@steipete
steipete marked this pull request as ready for review September 16, 2026 17:01
Read /tasks and /status task snapshots through the canonical accepted-write
fence and prepared read owner, preserving session visibility and strict
agent-local counts without synchronous SQLite refresh.

Keep the original race guards after a scoped worker-row fixture witness,
and repair status fixtures to exercise successful replies. Include the
canonical prepared-runtime fixture correction from 2e73d8e.
Preserve current-main terminal freshness, indexed identifiers, and expanded
publication coverage while retaining asynchronous chat task status reads.
Prepare persisted test fixtures before publication race guards without
changing their deadlines, assertions, or the separate cold-read regression.
@steipete
steipete changed the base branch from codex/async-gateway-task-page-stack-20260914 to main September 20, 2026 10:23
@steipete
steipete force-pushed the codex/async-chat-task-status-stack-20260916 branch from 91a5b1d to 83b558b Compare September 20, 2026 10:24
@steipete steipete changed the title refactor(tasks): prepare chat task status asynchronously fix(tasks): keep chat status reads responsive Sep 20, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 20, 2026
Preserve main's fixed-prefix owner preparation and captured worker context
for canonical owner rows while retaining session and agent status selectors.
Resolve the query-test imports without dropping either contract or fixture.
Carry the asynchronous status readers onto the current canonical read and projection owners. Preserve settled-task and owner-currentness semantics. Join the lineage fixture accepted-event fence before its unchanged leak guard; pinned-main timing controls reproduce and fix premature polling.
Preserve the asynchronous status feature and its current-owner filtering while integrating the landed Stylelint and identifier-fixture repairs. Keep canonical identifier normalization with its existing write and Doctor owners; no duplicate fixture change remains.
@steipete
steipete merged commit aa5c648 into main Sep 20, 2026
221 checks passed
@steipete
steipete deleted the codex/async-chat-task-status-stack-20260916 branch September 20, 2026 23:59
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 21, 2026
…aw#149738)

Read /tasks and /status task snapshots through the canonical accepted-write
fence and prepared read owner, preserving session visibility and strict
agent-local counts without synchronous SQLite refresh.

Keep the original race guards after a scoped worker-row fixture witness,
and repair status fixtures to exercise successful replies. Include the
canonical prepared-runtime fixture correction from 2e73d8e.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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