Skip to content

perf(cron): compact worker replies for run transcripts - #163885

Merged
vincentkoc merged 2 commits into
mainfrom
perf/cron-history-binding-20261003
Oct 8, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
perf/cron-history-binding-20261003

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Viewing a cron run transcript transferred every full history record for that job to the Gateway twice, including recovery state the transcript does not use.

User Impact

Transcript responses, pagination cursors and current access checks stay unchanged. The Gateway receives compact binding facts instead of recovery payloads. No configuration, migration or operator action is required.

Why This Change Was Made

The existing admitted cron read worker selects the unique recorded transcript and computes its cursor binding. The Gateway retains both fresh reads, authority and sharing checks, and physical transcript-owner verification. Bulk cron.runs reads stay unchanged.

Full worker-side history acquisition still occurs. This reduces unnecessary worker-to-Gateway transfer; it does not optimize SQL scanning or worker startup.

Evidence

  • The real registered-handler regression uses 32 same-job records with 64 KiB recovery strings. Historical matched replies shrank from 2,117,941 to 175 serialized JSON bytes each. This is a size proxy, not exact structured-clone wire bytes. The baseline passed existing response/cursor/no-main-thread-SQL assertions before failing the new compact-reply assertion.
  • Integrated head d995acf9dcb80cd7801ba12abb5de185504a4db4: 34/34 focused cases passed on Node 24.16.0/macOS arm64: Doctor fixture 3, cron startup recovery 1, transcript history 7, publication authority 3, bulk runs 14, read-only worker 6. Tests cover original nine-field cursor identity, archived pagination, combined selectors, incomplete duplicates, sharing, retention and physical ownership.
  • Current head f30992390535c484e3171ba72beeea140d07e9c2 only adds an export-preserving publication-test mock and removes its one obsolete mock-baseline entry. The affected 3/3 cases passed again; independent review found no assertion or isolation regression. Production and all other test files remain byte-identical to the integrated proof.
  • Packaged build passed in 232.397s. Its existing report-only UI check reports startup JS 373,875 B against 373,454 B (421 B over). UI/build/baseline inputs are unchanged by this PR; this is not a strict UI budget pass.
  • Targeted formatting, diff checks, mock-export rule and production typecheck passed. The redundant local changed-file replay was intentionally stopped through its task-owned compiler owner after exact-head hosted CI passed and the PR merged (exit 143, not a passing local full-gate result). Its completed guards, formatting, production types and completed test typegraphs had passed. Required CI passed on exact head f30992390535c484e3171ba72beeea140d07e9c2, including production and test types. The PR rollup has 70 successful checks and no failures; skipped checks are not coverage.
  • Testbox timed out during source synchronization before any proof command ran and stopped cleanly. The above execution used the permitted trusted-source local fallback; Testbox supplied no execution evidence. Separately, hosted Linux/Node 24.19.0 logs confirm all three Doctor cases and the following cron-startup recovery case passed.
  • The original production patch passed independent source review and P0–P2 autoreview. The rebase kept that patch identical. One historical timing pair measured wall 1,067.457 → 692.849 ms but CPU user/system 739.840/105.251 → 819.978/103.754 ms. No stable latency, CPU or peak-memory gain is claimed.

Production: +132/−45 (net +87), for the typed compact request/result and worker selection boundary; Gateway selection/hash code is removed. Tests: +188/−116 (net +72). One obsolete test-mock allowance is removed.

Previous CI prerequisite

The previous CI run failed two Doctor fixture cases on old head 7ca3c4bba5b34df571337da48510b12a8bfa534a. Cancelled jobs are not coverage.

This branch now incorporates upstream worker-retirement fix 68f76fc9 and shared-state drain fix #164805, through frozen base d51917edde3d3949a535131b97dbc6f43c4ea6ef. Both Doctor helpers await canonical agent and shared-state cleanup before launching their child. All three Doctor cases now pass locally without added retries or timeout changes. Current required CI now passes; no inherited-CI or admin exception is requested.

Review disposition

Fresh ClawSweeper review completed for the exact head at 06:14 UTC on October 8: no findings, security issues, before-merge items or rank-up moves. Direct maintainer review accepts the existing-worker boundary as the canonical fix. The review correctly notes that the performance proof is a registered-handler harness with real SQLite workers, not an installed Gateway/CLI benchmark; no broader performance claim is made. The needs-human marker is satisfied by this maintainer disposition, not a CI waiver.

Landed

Native squash landing verified on October 8 at 06:24:50 UTC as 467fc82c4fd9. All six source/test blobs match the reviewed head. The landed baseline delta removes only this mock allowance and preserves unrelated newer-main baseline changes. The commit is an ancestor of current remote main.

@vincentkoc vincentkoc self-assigned this Oct 3, 2026
@clawsweeper

clawsweeper Bot commented Oct 3, 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.

@vincentkoc
vincentkoc marked this pull request as ready for review October 3, 2026 00:11
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: M labels Oct 3, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Oct 3, 2026
@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 8, 2026, 2:14 AM ET / 06:14 UTC (Revision 3).

ClawSweeper review

What this changes

This PR makes the Cron read worker return compact transcript identity facts instead of full run-history records while preserving transcript responses and access checks.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful and source-correct, with meaningful real-worker harness evidence but no current-patch proof through the shipped entry point.
Proof confidence 🦐 gold shrimp (3/6) Not applicable: The MEMBER-authored PR is exempt from ordinary contributor proof requirements. Its reported registered-handler execution exercises compact replies through real workers; predecessor screenshots do not prove this optimization. Production bytes match the integrated tested head, and no schema, stored format, config, or migration changes are introduced.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes
Reason: Removing repeated multi-megabyte recovery payload transfers is worthwhile internal resource work. It preserves the existing product contract and makes no unsupported user-visible speed claim.

Merge readiness

✅ Ready for maintainer review

Keep open: this is a distinct, useful optimization with no actionable patch findings. The author’s MEMBER association also prevents automatic closure.

Priority: P2
Reviewed head: f30992390535c484e3171ba72beeea140d07e9c2

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No current-patch installed Gateway or CLI proof is supplied; the strongest execution evidence is the registered-handler harness with real SQLite workers. The author reports the baseline failing the compact-reply assertion; this read-only review did not rerun it.
Agent review details

How this fits together

Cron stores automation run history in SQLite. When a user opens a run transcript, a worker selects its recorded conversation and the Gateway checks current access before returning messages.

flowchart TD
  A[Run transcript request] --> B[Gateway access checks]
  B --> C[Cron read worker]
  D[Stored run history] --> C
  C --> E[Compact transcript identity]
  E --> F[Physical transcript and fresh access verification]
  F --> G[Transcript page and cursor]
Loading

Technical review

Best possible solution:

Keep transcript selection in the existing admitted worker and retain fresh authorization and final publication checks in their current Gateway owners.

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

Not applicable as a functional bug: this is an internal performance improvement. Source confirms the existing full-history transfer, and the author reports a baseline-failing compact-reply regression.

Is this the best way to solve the issue?

Yes: moving selection into the existing worker avoids unnecessary transfers while preserving the original codec, cursor bytes, bulk-history path, and access boundaries.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 594335a38e5a.

Provenance checked

Testing

Proof path: in-process harness. Added test files: 2.

Security

None.

Evidence

What I checked:

  • Introduced production behavior: The worker retains the existing row reader and partition filter, selects a unique matching run, rejects incomplete or ambiguous identity, and hashes the same ordered nine fields previously hashed by the Gateway. (src/cron/store/read-only.worker.ts:23, f30992390535)
  • Publication safeguards preserved: Both fresh history reads remain. Physical transcript ownership, current client/runtime authority, current sharing, store identity, and final response checks remain with the Gateway and shared retained-transcript publication owner. (src/gateway/server-methods/cron-history.ts:154, f30992390535)
  • Meaningful worker-boundary regression: The existing registered-handler case now stores 32 records containing 64 KiB recovery strings, verifies archived messages and original cursor identity, and observes pass-through real worker replies to require absent recovery payloads and replies smaller than 1,024 bytes. (src/gateway/server-methods/cron.history.test.ts:314, f30992390535)
  • Reported execution and reuse scope: The captured PR body reports 34 focused passing cases on d995acf and three affected publication cases passing on the current head. Production bytes are identical between those heads. The reported reply-size proxy is 2,117,941 → 175 serialized JSON bytes; no stable CPU, latency, or memory gain is claimed. Body source identity: 0c20345cee5e8ce977935b076a51fcf2b643176acf9454240f01bc22a3149caf. (f30992390535)
  • Still distinct from current main: The relevant production and test files have no main-side changes since the merge base; current main retains full-history transcript replies. The host-verified test merge has the exact main and PR-head parents. No supplied related merged PR implements this optimization. (src/gateway/server-methods/cron-history.ts:86, 594335a38e5a)
  • Feature-history routing and original intent: Current-main history repeatedly connects Peter Steinberger to these owners. refactor(cron): read run history through its worker #158222 established worker-owned history reads; refactor(cron): own retained run transcript access #158776 established exact retained transcripts, cursor binding, and fresh publication checks. This patch preserves those purposes. (src/gateway/server-methods/cron-history.ts:86, 718bf2ccae9f)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

PR surface

Source +87, Tests +72, Other -1. Total +158 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 4 132 45 +87
Tests 2 188 116 +72
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 7 320 162 +158

Review metrics

Metric Value Why it matters
Reported worker reply size 2,117,941 → 175 serialized JSON bytes per matched reply The registered-handler fixture demonstrates a substantial transfer-size reduction, without establishing exact wire bytes or runtime speed.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P2: This bounded resource-efficiency improvement affects transcript inspection without changing its visible behavior.
  • 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 need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-03T00:17:18.358Z sha 7ca3c4b :: needs maintainer review before merge. :: none
  • reviewed 2026-10-03T00:25:17.203Z sha 7ca3c4b :: needs maintainer review before merge. :: none

@vincentkoc
vincentkoc force-pushed the perf/cron-history-binding-20261003 branch from 7ca3c4b to f309923 Compare October 8, 2026 06:06
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head f30992390535c484e3171ba72beeea140d07e9c2. This incorporates the upstream Doctor drain fixes, retains the patch-identical production optimization, and preserves real exports in the publication-test mock. Current proof and remaining CI/typegraph gates are recorded in the PR body.

@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Oct 8, 2026
@vincentkoc
vincentkoc merged commit 467fc82 into main Oct 8, 2026
142 checks passed
@vincentkoc
vincentkoc deleted the perf/cron-history-binding-20261003 branch October 8, 2026 06:24
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 9, 2026
* improve(cron): return compact worker bindings for run transcripts

* test(cron): preserve read-only module exports in publication mock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M 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