Skip to content

fix(media): avoid blocking cold task lookups - #148583

Merged
steipete merged 9 commits into
mainfrom
codex/async-media-owner-config-preparation-stack-20260914
Sep 21, 2026
Merged

steipete merged 9 commits into
mainfrom
codex/async-media-owner-config-preparation-stack-20260914

Conversation

@steipete

@steipete steipete commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Cold media status, prompt, and duplicate lookups could block on configuration state when a restored task lacked a recorded requester, or lose that task while preparing requester facts.

User Impact

Restored media tasks remain visible to their requester, completed or failed tasks produce the correct duplicate decision, and requester preparation uses the existing asynchronous config owner. A configuration-source change during the lookup rejects the interrupted lookup instead of returning missing or stale requester facts. Ordinary same-source config reloads preserve the captured snapshot. No schema, retention, provider, permission, or update migration changes are required.

Why This Change Was Made

One preparation serves all enabled media prompt sections. Recorded identities and agent-scoped session keys avoid config loading; terminal-only status and prompt reads do too. After config preparation succeeds or fails, the lookup refreshes task rows and rechecks the captured owners before selection. The shared config reader exposes its existing source-currentness check so callers can retain it across subsequent awaits without duplicating selector policy.

Evidence

Candidate f955720b752c94d9c9966ac004944286c86ab093 carries the media repair onto main commit 829a681991220bcc2ec63ff5d7eebac8d3e2eea0. All 69 focused tests across five files, 32 selected changed-file requirements, fresh independent P0–P2 review, and the normal full pnpm build passed. Two real-reader source-change regressions failed on the prior implementation and passed after repair; the same-source reload control passed in both cases. The original cold shared-prompt negative control remains retained at its original source identity.

Fresh compiled Node 24.21.0 and Bun 1.4.2 processes passed five scenarios each: terminal-only config avoidance, cold requester/prompt/duplicate lookup, persisted success, persisted failure, and reopen. Construction, close, six SQLite query methods, and Atomics.wait were positively calibrated and stayed zero during every measured phase and final cleanup. Feature-import counts were also zero. Canonical artifact ownership and matching before/after inventories bound 47,429 source entries, 14,015 artifacts, installation metadata, package manifests, and maintained links. Transitive dependency payload bytes were not exhaustively inventoried. Native fixture writes and SQLite capability/library selection are setup, outside the measured read interval; no external provider, updater, full Gateway, held-lock, fault-injection, or speedup claim is made.

The historical Doctor-path failure in CI run 35533014346 remains unexplained. This successor addresses the demonstrated config-source races and does not claim to repair that earlier failure. Fresh exact-head CI and native maintainer gates remain required before landing.

Per-file test cost

Measured at the unchanged f955720b752c94d9c9966ac004944286c86ab093 candidate on macOS arm64, Node 24.21.0, pnpm 12.4.0. Each file ran once, serially, using pnpm test <file> --maxWorkers=1; external wall time includes the full command and its normal preparation.

Test file Cases External wall Vitest invocation Case execution total
src/agents/media-generation-task-status.cold.test.ts 4 passed 101.91 s 92.07 s 9.311 s
src/agents/media-generation-task-status-shared.test.ts 32 passed 3.35 s 1.86 s 0.133 s

The cold suite needs the real persisted task/config/worker boundary to prove requester selection, config-source rejection, and absence of parent-thread SQLite calls through cleanup. A mocked reader cannot establish that contract; the shared suite provides the cheaper decision/race coverage. This cold run had a normal compiled-worker cache miss: automatic worker preparation took 57.61 s, and Vitest attributed 84% of its invocation to transformation. All 47,429 tracked source entries matched before and after each command. The status test file only added a three-line owner mock, so its unchanged cases did not receive an additional cost run.

CI per-file timing is separate: it has not been extracted from the current CI run 35633562286. The measurements above are local command timings, not inferred CI file costs or whole-job durations.

The successful exact-head CI workflow took 1,617 seconds (26 minutes 57 seconds) from creation at 17:40:59 UTC to completion at 18:07:56 UTC on September 21, 2026. The final openclaw/ci-gate job completed at that same timestamp. This is total workflow elapsed time, including queueing, setup, and parallel jobs; it is not a per-file test measurement.

@clawsweeper

clawsweeper Bot commented Sep 14, 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.

@steipete
steipete marked this pull request as ready for review September 14, 2026 22:45
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Sep 14, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 14, 2026
@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed September 21, 2026, 2:20 PM ET / 18:20 UTC (Revision 32).

ClawSweeper review

What this changes

The PR prepares requester configuration asynchronously for media status, duplicate checks, and prompt context, while rejecting stale lookups and refreshing task records after preparation.

Merge readiness

⛔ Needs changes before merge - 1 item remains

The repair remains necessary on current main, and the reviewed patch has no blocking correctness or security findings. The maintainer-authored PR should remain open for normal landing.

Priority: P2
Reviewed head: f955720b752c94d9c9966ac004944286c86ab093

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, maintainable repair with relevant runtime evidence and no actionable code findings; the remaining follow-up concerns test-cost reporting.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The captured body records compiled Node and Bun runs through the changed media lookup owner using persisted tasks, observing correct status/duplicate outcomes and zero parent-thread SQLite activity through cleanup. Real-reader regressions supplement that bounded evidence; no broader provider or upgrade proof is claimed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured body records compiled Node and Bun runs through the changed media lookup owner using persisted tasks, observing correct status/duplicate outcomes and zero parent-thread SQLite activity through cleanup. Real-reader regressions supplement that bounded evidence; no broader provider or upgrade proof is claimed.
Evidence reviewed 8 items Introduced production change: The pinned introduction delta replaces synchronous requester configuration loading with the existing asynchronous reader, refreshes tasks after configuration preparation, and validates captured owners before selection.
Current main still needs the repair: Current main's legacy requester resolver still calls getRuntimeConfig synchronously. The existing asynchronous configuration capability does not itself repair these media callers.
Latest release comparison: The same synchronous requester fallback is present in v2026.9.5. Its source was inspected through GitHub after the local release blob could not be retrieved.
Findings None None.
Security None None.

How this fits together

Media task lookup combines persisted background-task records with requester identity and enabled media tools. Its results feed agent prompt context, status responses, and decisions about whether generation would duplicate existing work.

flowchart TD
  A[Session and enabled media tools] --> B[Read current task records]
  B --> C{Requester already recorded?}
  C -->|Yes| E[Validate owners and select tasks]
  C -->|No| D[Prepare configuration asynchronously]
  D --> B
  E --> F[Prompt facts and status]
  E --> G[Duplicate decision]
Loading

Before merge

  • Complete next step (P2) - Complete the prior test-cost follow-up with per-file CI durations for the cold and shared suites, or document that those measurements were not retained; the reported workflow total does not establish per-file cost.
Agent review details

Security

None.

PR surface

Source +92, Tests +445, Docs +2. Total +539 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 3 109 17 +92
Tests 4 452 7 +445
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 563 24 +539

Review metrics

Metric Value Why it matters
Focused test cost Cold suite: 101.91 s wall; shared suite: 3.35 s wall The cold suite's reported cost includes worker preparation and protects the real persisted-task/config boundary; CI per-file timings remain unreported.

Technical review

Best possible solution:

Keep media requester preparation with the existing asynchronous config owner and preserve fresh task selection, recorded-identity fast paths, and source-currentness checks.

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

Yes, source establishes the cold path: a persisted media task without requester identity reaches synchronous configuration loading on current main. The PR records failing negative controls and passing repaired boundary runs; this review did not execute them.

Is this the best way to solve the issue?

Yes. The patch reuses the canonical asynchronous config reader and task owner, preserving selection semantics while refreshing records after the added await.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 8a26ae487b5f.

Labels

Label justifications:

  • P2: This fixes bounded cold media lookup blocking and stale task selection without evidence of a widespread urgent outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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): The captured body records compiled Node and Bun runs through the changed media lookup owner using persisted tasks, observing correct status/duplicate outcomes and zero parent-thread SQLite activity through cleanup. Real-reader regressions supplement that bounded evidence; no broader provider or upgrade proof is claimed.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured body records compiled Node and Bun runs through the changed media lookup owner using persisted tasks, observing correct status/duplicate outcomes and zero parent-thread SQLite activity through cleanup. Real-reader regressions supplement that bounded evidence; no broader provider or upgrade proof is claimed.

Evidence

What I checked:

  • Introduced production change: The pinned introduction delta replaces synchronous requester configuration loading with the existing asynchronous reader, refreshes tasks after configuration preparation, and validates captured owners before selection. (src/agents/media-generation-task-status-shared.ts:126, f955720b752c)
  • Current main still needs the repair: Current main's legacy requester resolver still calls getRuntimeConfig synchronously. The existing asynchronous configuration capability does not itself repair these media callers. (src/agents/media-generation-task-status-shared.ts:98, 8a26ae487b5f)
  • Latest release comparison: The same synchronous requester fallback is present in v2026.9.5. Its source was inspected through GitHub after the local release blob could not be retrieved. (src/agents/media-generation-task-status-shared.ts, ec9c1a13db89)
  • Boundary and race coverage: The cold suite exercises real persisted tasks, requester inclusion and exclusion, status and duplicate results, config-source changes during both task reads, and same-source snapshot preservation. Shared tests cover completion/deletion during successful or failed configuration preparation and owner retirement before continuation. Tests were inspected, not executed in this read-only review. (src/agents/media-generation-task-status.cold.test.ts:70, f955720b752c)
  • Recorded runtime evidence: The captured PR body reports five production-path scenarios each in fresh compiled Node 24.21.0 and Bun 1.4.2 processes: terminal-only avoidance, cold requester/prompt/duplicate lookup, persisted success, persisted failure, and reopen. Calibrated parent-thread SQLite and Atomics.wait counters remained zero through cleanup. This supports the bounded lookup claim; it does not establish provider, full-Gateway, upgrade, or speedup claims. (f955720b752c)
  • Review continuity and test-cost evidence: The previous review examined this same head and had no code findings. Its requested local measurements are now supplied: cold suite 101.91 seconds wall / 9.311 seconds case execution, and shared suite 3.35 seconds wall / 0.133 seconds case execution, with the cold boundary's cost explained. The body explicitly says per-file CI timings remain unextracted; the 1,617-second workflow total is not a substitute for them under the test-cost policy. Public docs: docs/help/testing/writing-tests.md. (docs/help/testing/writing-tests.md, f955720b752c)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record per-file CI timings for the cold and shared suites, or document that the completed run did not retain those measurements.

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 (31 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-20T10:14:12.939Z sha aa96919 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-20T10:47:23.749Z sha aa96919 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-20T11:30:47.037Z sha d49b6f9 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-20T17:02:47.578Z sha d49b6f9 :: blocked before merge. :: none
  • reviewed 2026-09-20T18:37:55.707Z sha c22d417 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-20T19:57:35.709Z sha 6f8ffe8 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-20T20:47:36.159Z sha 6f8ffe8 :: needs changes before merge. :: none
  • reviewed 2026-09-21T17:49:37.839Z sha f955720 :: needs changes before merge. :: none

@steipete
steipete marked this pull request as draft September 15, 2026 14:20
@steipete
steipete marked this pull request as ready for review September 15, 2026 14:26
@steipete
steipete marked this pull request as draft September 15, 2026 16:51
@steipete
steipete marked this pull request as ready for review September 15, 2026 17:02
@steipete
steipete marked this pull request as draft September 15, 2026 20:06
@steipete
steipete marked this pull request as ready for review September 15, 2026 20:49
@steipete
steipete marked this pull request as draft September 15, 2026 23:18
@steipete
steipete marked this pull request as ready for review September 15, 2026 23:27
@steipete
steipete marked this pull request as draft September 16, 2026 04:46
@steipete
steipete marked this pull request as ready for review September 16, 2026 05:19
@steipete
steipete marked this pull request as draft September 16, 2026 08:47
@steipete
steipete marked this pull request as ready for review September 16, 2026 09:25
@steipete
steipete marked this pull request as draft September 16, 2026 12:01
@steipete
steipete marked this pull request as ready for review September 16, 2026 14:27
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 16, 2026
@openclaw-barnacle openclaw-barnacle Bot added channel: signal Channel integration: signal channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: zalo Channel integration: zalo channel: zalouser Channel integration: zalouser app: android App: android app: ios App: ios app: macos App: macos gateway Gateway runtime extensions: copilot-proxy Extension: copilot-proxy extensions: diagnostics-otel Extension: diagnostics-otel extensions: llm-task Extension: llm-task extensions: lobster Extension: lobster extensions: memory-core Extension: memory-core extensions: memory-lancedb Extension: memory-lancedb security Security documentation docker Docker and sandbox tooling channel: feishu Channel integration: feishu extensions: device-pair channel: irc extensions: acpx extensions: anthropic extensions: minimax extensions: cloudflare-ai-gateway extensions: byteplus labels Sep 20, 2026
Carry the cold task lookup repair onto current main and preserve the aggregate prompt owner. Resolve legacy requester config once for enabled media, refresh task rows after preparation, and pass captured facts to the pure formatter. Keep terminal-only config bypass and live owner checks.
Carry the qualified Media repair onto main with the formatter callback fix and approved UI budget baseline. Preserve the Media implementation, tests, and documentation byte-for-byte; retain prior build and runtime evidence at its original source identity.
Carry media requester preparation onto current main while preserving shared prompt facts and persisted duplicate decisions. Expose the existing captured config reader source guard and retain it across task refresh and selection; ordinary same-source runtime snapshots remain fixed for the lookup.

Validation: 69 focused tests pass, including two demonstrated selector-drift regressions and the same-source reload control. Fresh independent P2 review is clean. Broader changed gates and full compiled qualification continue separately; historical Doctor CI cause remains unproven.
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

agents Agent runtime and tooling 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