Repository navigation
fix(media): avoid blocking cold task lookups - #148583
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs changes before merge. Reviewed September 21, 2026, 2:20 PM ET / 18:20 UTC (Revision 32). ClawSweeper reviewWhat this changesThe 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 Review scores
Verification
How this fits togetherMedia 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]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +92, Tests +445, Docs +2. Total +539 across 8 files. View PR surface stats
Review metrics
Technical reviewBest 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. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (31 earlier review cycles; latest 8 shown)
|
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.
|
Merged via squash.
|
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
f955720b752c94d9c9966ac004944286c86ab093carries the media repair onto main commit829a681991220bcc2ec63ff5d7eebac8d3e2eea0. All 69 focused tests across five files, 32 selected changed-file requirements, fresh independent P0–P2 review, and the normal fullpnpm buildpassed. 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.waitwere 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
f955720b752c94d9c9966ac004944286c86ab093candidate on macOS arm64, Node 24.21.0, pnpm 12.4.0. Each file ran once, serially, usingpnpm test <file> --maxWorkers=1; external wall time includes the full command and its normal preparation.src/agents/media-generation-task-status.cold.test.tssrc/agents/media-generation-task-status-shared.test.tsThe 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-gatejob 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.