Skip to content

fix: Template details take too long to load - #193124

Merged
Patrick-Erichsen merged 3 commits into
mainfrom
fix/templates-detail-latency-20261104
Nov 5, 2026
Merged

Patrick-Erichsen merged 3 commits into
mainfrom
fix/templates-detail-latency-20261104

Conversation

@Patrick-Erichsen

@Patrick-Erichsen Patrick-Erichsen commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: opening a Template’s details leaves its workspace-file and content rows loading while independent registry requests run one after another.

User Impact

Template details load faster without changing their contents, exact-release selection, visibility checks, artifact integrity, or preview/apply behavior. No configuration changes or migration are required.

Why This Change Was Made

Read package metadata, exact-release metadata, and the archive concurrently, then reuse the release’s artifact metadata instead of making a redundant artifact-resolution request. Archive content is not consumed before the existing identity and integrity checks pass. A request-owned abort cancels unfinished speculative downloads on metadata failure, and staged downloads are always cleaned up.

The parser and integrity helpers move unchanged to the existing artifact owner to keep the source module within its line limit. No cache, endpoint, dependency, or configuration surface is added.

Evidence

  • Isolated real OpenClaw Gateways against the same local ClawHub installation and hash-verified published Research monitor 0.1.2 archive: five interleaved fresh-connection loads per arm. Average 1012.94 → 331.52 ms (67.27% lower; 3.06× faster); median 954.20 → 307.49 ms; p95 1179.77 → 459.37 ms. Every complete JSON response was deeply equal. This success-path measurement predates the failure-path cancellation repair and helper relocation; final-code browser/production evidence is recorded separately below.
  • Rerunnable real-Gateway benchmark: scripts/bench-template-detail.mts (at least five samples, response parity, per-run host load, no credential output). It measures authenticated connection plus full verified detail response, not CLI startup or browser INP.
  • Focused source/artifact/Gateway tests pass. Source suite includes concurrency/no-consumption-before-validation, redundant-request removal, failure cleanup, and genuinely pending-download cancellation. Three new regression cases fail on unchanged baseline (3 failed, 34 passed); baseline checkout restored afterward.
  • Final-code real-browser baseline/candidate flows render identical Research monitor workspace files and nonempty SOUL.md previews. Detail RPC: 669.57 → 249.52 ms in these single illustrative captures (not a multi-run latency claim); preview RPC succeeds on both. Automation-to-visible-detail wall time: 1011.71 → 507.30 ms. No browser page errors. The synthetic empty session produces an unrelated mcp.app.discover access refusal; all Template RPCs succeed. Before/after screenshots are attached below.
  • Targeted template and scripts typechecks, four-file lint, formatting, and git diff --check pass.
  • Independent read-only review of exact commit 7e0d2c402e6f182402e8c027d9315fb42721d7d8 confirms both cancellation and benchmark-token typing findings resolved, with no remaining blockers in the four-file scope. The reviewer did not rerun checks. Local ClawSweeper completed the entire committed range c8094c112b45a3b7ab378af7668be0f60cafd0cd..7e0d2c402e6f182402e8c027d9315fb42721d7d8 (high reasoning, read-only source correctness/security scope): no actionable findings; no tests or runtime benchmarks were run by that review.
  • Author simplify pass removes one redundant primary registry lookup and the serial critical path without adding cache/configuration ownership. Whole-change delta: production +81 net lines, tests +72, benchmark +91; runtime growth is parallel coordination and explicit download lifecycle ownership.
  • UI proof reused generated production UI assets; no production UI source changed. The isolated UI build emitted assets but reported startup-size budget violations outside the touched source scope; it is not claimed as a green full UI build.

No production OpenClaw Gateway was rebuilt or restarted. This is an OpenClaw-side optimization; it does not itself deploy new Gateway code.

Before - complete Template details on baseline Gateway

After - equivalent Template details on candidate Gateway

Before - SOUL.md preview on baseline Gateway

After - SOUL.md preview on candidate Gateway

Current-production final-code benchmark

Final commit 7e0d2c402e6f182402e8c027d9315fb42721d7d8 versus unchanged baseline c8094c112b45a3b7ab378af7668be0f60cafd0cd, using already-running isolated real Gateways on ports 19561/19562. Both processes were verified bound to OPENCLAW_CLAWHUB_URL=https://clawhub.ai. Workload: exact published @openclaw/[email protected]; five serial ABAB pairs, each over a fresh authenticated Gateway connection through the full verified archive/extraction/detail path. Process/module startup is excluded. The >=2x average speedup target passes; full JSON deep equality passes for all ten responses.

Metric (ms) Baseline Candidate
Average 3620.30 1049.26
Median 3343.90 988.84
p95 (5 samples/arm) 5042.19 1199.79
Min-max 3100.07-5042.19 973.29-1199.79

Average 3.45x faster / 71.02% lower. Per-sample 1/5/15-minute host load was recorded; observed 1-minute load 9.62-10.55. Initial slower baseline sample is retained, not discarded. Source-owned primary registry reads fall from four to three, with the three remaining independent reads concurrent; archive-internal HTTP work is not included in that count. No cache is added.

node --import ./scripts/tsx.mjs scripts/bench-template-detail.mts   --baseline-config /path/to/baseline/openclaw.json   --candidate-config /path/to/candidate/openclaw.json   --output /path/to/current-production-gateway-ab.json

This measures current production ClawHub, not a new shared backend deployment. Shared backend PR openclaw/clawhub#4443 merged as 923099b7bb4fa9de01fe157722403434af139ab6; its exact-SHA Deploy Test passed, but production Deploy 41951554456 refused unrelated large-index deletion. That guard was not bypassed. Post-shared-deployment validation remains blocked. This PR remains an OpenClaw-only proposal and does not update or restart the user's production Gateway.

All four attached before/after PNGs were subsequently loaded and decoded from the rendered PR (1440x1050 each).

CI fixture repair

The original exact-head CI checks-node-changed job failed in server-templates-add-authority.e2e.test.ts with Downloaded Template package manifest is invalid. The CI classifier marked attribution unknown (no matching main job and annotation-only discovery); the completed job log was subsequently inspected directly.

The fixture and manifest reader were both byte-identical to baseline c8094c112b45a3b7ab378af7668be0f60cafd0cd: the fixture declared the retired openclaw.template: template.json, while the reader accepts only package-relative CLAW.md with frontmatter. A bounded owning-reader reproduction on baseline and candidate, for both allowed/revoked fixture shapes, rejects the old selector with invalid_package_metadata and admits the canonical manifest with package dependencies and cron declarations intact. This establishes the inherited fixture defect, not a passing full Gateway replay.

The follow-up changes only that existing E2E fixture: point the package selector at CLAW.md, move the unchanged manifest JSON into its frontmatter, retain the original heading, and remove the obsolete JSON artifact. All authorization, revoked-admin, persistence, and effect assertions remain unchanged. Production source is unchanged from measured/reviewed 7e0d2c402e6f182402e8c027d9315fb42721d7d8, so the benchmark and screenshots above remain applicable.

Changed-file lint, formatting, and git diff --check pass. Local full E2E preparation refused because managed-Gateway artifact separation could not be verified; no artifacts were rebuilt and that guard was not bypassed. The supported isolated runner requires Linux and is unavailable on this Mac. Full real-Gateway confirmation subsequently passed on fixture commit 665fab132433ca7563f14c1b19669dd86ae0a54a: checks-node-changed job 127001030795. The original authority test passed in 14.77 seconds (53.15 seconds for its full isolated invocation), and the trusted-plugin sibling passed in that job. This supersedes the local E2E verification gap; overall CI is not yet claimed green.

Published fixture-only follow-up: 665fab132433ca7563f14c1b19669dd86ae0a54a. Independent read-only review reports no findings or boundary weakening: manifest declarations are preserved and all authentication, consent, revocation, before-effect gating, settlement, and installed-state assertions remain unchanged. The reviewer did not execute tests.

Scoped test-line allocation

CI on 665fab132433ca7563f14c1b19669dd86ae0a54a then failed only the completed baseline-ratchet job's test-line check: 6,477,280 lines versus ceiling 6,477,260; this change has +71 net test LF lines. Preserve the regression tests rather than deleting unrelated coverage or weakening assertions. Per the repository's comparison-aware test-budget policy, commit 5316e2f03939a1fc72f2a11f3dd3dc3c7ec3633e adds the separate config/test-lines-allocations/templates-detail-parallel-artifact.txt record for exactly those 71 net lines (+72 source regression lines and -1 canonical authority-fixture line). It covers concurrent-read admission without early extraction, elimination of the redundant artifact lookup, completed-download cleanup on metadata/integrity failure, and genuinely pending-download cancellation. The shared scalar is unchanged.

The staged checker passes against both original base c8094c112b45a3b7ab378af7668be0f60cafd0cd and CI's observed comparison base 8526701724c109fd911837ba0fe4585b42fa50a5: local tree 6,473,470; effective ceiling 6,473,499; slack 29. The new record is bounded to actual owned growth; no inherited debt or blanket allowance is added. git diff --check passes. No production or test behavior changed after the passing real-Gateway replay. Replacement exact-head CI remains the final broad verification gate.

Exact-head CI: attributed inherited test-budget debt

At head 5316e2f03939a1fc72f2a11f3dd3dc3c7ec3633e, checks-node-changed passed again, including the real-Gateway authorization tests. checks-fast-baseline-ratchets failed only the test-line ceiling on CI's newer merged snapshot: 6,477,752 lines versus 6,477,701 ceiling, 51 over. Independent index-only reproduction of exact comparison base 83a74589d30bbab769dd7c14d164619fd960404e measures 6,477,681 lines versus 6,477,630 ceiling: already 51 over, delta zero. This PR's +71 LF lines and separate +71 allocation leave inherited debt unchanged. No shared scalar, inherited-debt allowance, or unrelated tests were altered. The CI run is now terminal: all three PostgreSQL conformance jobs passed, with no checks still pending in this run. The final aggregate gate propagates the inherited test-line failure; overall CI remains red.

Post-deployment production-backed detail validation

The former shared-deployment blocker is resolved: independently verified Deploy Test 41952356152 and production Deploy 41952769498 both completed successfully at exact backend SHA 7d4aa932ed113fc289bcd2e936d8f667d3cd2958. The backend compatibility repair preserves the existing index rather than bypassing its deletion guard.

After those receipts, reran the committed scripts/bench-template-detail.mts workload against https://clawhub.ai: five serial ABAB pairs, fresh authenticated connections, exact @openclaw/[email protected], full verified archive/extraction/detail path. Isolated baseline c8094c112b45a3b7ab378af7668be0f60cafd0cd and candidate 5316e2f03939a1fc72f2a11f3dd3dc3c7ec3633e Gateways used ports 19562/19561. Candidate production-source blobs are unchanged from reviewed/measured 7e0d2c402e6f182402e8c027d9315fb42721d7d8. Process/module startup is excluded; every sample, including the slower first baseline, is retained.

Metric Baseline Candidate
Average 3622.78 ms 1021.85 ms
Median 3226.98 ms 992.66 ms
p95 (five samples) 4896.35 ms 1127.31 ms
Min–max 3170.84–4896.35 ms 948.81–1127.31 ms

Average 3.55x faster / 71.79% lower, passing the predeclared >=2x rule. Full JSON equality passes for all ten responses and against the saved pre-deployment response. Recorded 1-minute host load: 10.05–10.77. No cache was added. This is now shared-post-deployment, production-backed detail-read proof; it does not claim this OpenClaw PR has merged or been deployed. Both task-owned isolated processes were closed after measurement. Production work Gateway port 19455 was never restarted and remained HTTP 200. Prior screenshots and pre-deployment measurements above are preserved as separate evidence.

Terminal CI follow-up

Run 41954663511 completed at exact head 5316e2f03939a1fc72f2a11f3dd3dc3c7ec3633e. All PostgreSQL conformance jobs passed: 1/3, 2/3, and 3/3. No jobs remain pending. The final aggregate CI gate reports checks-baseline-ratchets finished with failure (selected=true), propagating the already-proven 51-line inherited test-budget debt above. No additional independent scoped failure appeared. The classifier's sampled-main comparison is informational; direct measurement of the exact CI comparison base establishes the inherited debt. No guard was bypassed and no CI rerun was dispatched. This closes the pending PostgreSQL observation; the PR remains open and unmerged.

@clawsweeper

clawsweeper Bot commented Nov 5, 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 scripts Repository scripts size: L labels Nov 5, 2026
@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Nov 5, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 5, 2026
@clawsweeper

clawsweeper Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR fetches independent Template registry data concurrently and reuses exact-release artifact metadata.

Example: Open details for @openclaw/[email protected].

  • Before: The reported production-registry benchmark averaged 3620.30 ms with serial registry reads.
  • After: The candidate averaged 1049.26 ms, with deeply equal complete responses across five interleaved samples per arm.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Strong shipped-path evidence supports the optimization; a narrow, verified test-budget failure remains before merge.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): The unchanged production implementation at 7e0d2c4 was exercised through isolated real Gateways against production ClawHub and through the browser detail/preview flow; inspected screenshots preserve contents, and five interleaved benchmark pairs report response parity and a 3.45× average speedup.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Template workspace-file and content rows remain loading while independent registry reads wait for each other.
Reason: The feature owner's proposal demonstrates a substantial latency reduction without adding product configuration, caches, or a competing implementation.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep this PR: it delivers a measured Template-detail speedup while preserving verification, but its added tests exceed the existing test-line budget and fail CI.

Priority: P2
Reviewed head: 665fab132433ca7563f14c1b19669dd86ae0a54a

Before merge

  • Allocate the added regression-test lines (P2) - These regressions contribute to 71 net added test lines, but this PR adds no allocation record. At the reviewed head, tracked tests contain 6,473,470 LF lines against a 6,473,428 effective ceiling, so the existing checker returns failure; exact-head CI confirms the test-lines failure. Add a justified 71-line record under config/test-lines-allocations/ as permitted by the testing policy, keeping the shared scalar and these distinct regression assertions intact.

Findings

  • [P2] Allocate the added regression-test lines — src/templates/clawhub-source.test.ts:432-435
Agent review details

How this fits together

The Control UI requests Template details through Gateway RPC; the Template source reads ClawHub metadata and archive bytes, verifies the selected release, and returns workspace files and resource descriptions.

flowchart LR
  A[Control UI] --> B[Gateway detail RPC]
  B --> C[Template source]
  C --> D[Package and release metadata]
  C --> E[Archive download]
  D --> F[Identity and integrity verification]
  E --> F
  F --> G[Verified detail response]
Loading

Technical review

Best possible solution:

Retain the existing-owner concurrency and verification design, and fund its justified regression growth with a separate 71-line allocation.

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

Current-main source exposes the serial request chain, and the PR supplies paired real-Gateway measurements; this read-only review executed no target code.

Is this the best way to solve the issue?

The change removes a redundant registry lookup and overlaps independent I/O using existing owners while preserving exact-release validation and archive cleanup.

Full review comments:

  • [P2] Allocate the added regression-test lines — src/templates/clawhub-source.test.ts:432-435
    These regressions contribute to 71 net added test lines, but this PR adds no allocation record. At the reviewed head, tracked tests contain 6,473,470 LF lines against a 6,473,428 effective ceiling, so the existing checker returns failure; exact-head CI confirms the test-lines failure. Add a justified 71-line record under config/test-lines-allocations/ as permitted by the testing policy, keeping the shared scalar and these distinct regression assertions intact.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Exact-release detail and source verification keeps the original intent (81662c5: Provide ordinary agents and resources through one-way Add while binding public package identity and verified artifact contents.)
  • Shared downloaded-artifact integrity checks keeps the original intent (3a8c71d: Consolidate duplicate digest and npm-integrity comparisons under one helper without changing validation.)
  • Canonical manifest in authority fixture keeps the original intent (refactor(templates): remove legacy manifest formats #192279: Retire experimental JSON manifests and require package-relative CLAW.md frontmatter; the fixture repair preserves declarations and authorization assertions.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

Acceptance criteria:

  • pnpm check:test-lines-ratchet --base c8094c1 --no-merge-base
  • pnpm check:baseline-ratchets --base c8094c1 --no-merge-base
  • git diff --check

What I checked:

  • Introduced change: The pinned introduction diff parallelizes package, release, and archive reads; retains verification before extraction; and gives the detail request ownership of download cancellation and cleanup. (src/templates/clawhub-source.ts:274, 665fab132433)
  • Current main still has the serial detail path: Current main awaits package metadata, release metadata, artifact resolution, and archive download in sequence; the merged catalog-overview improvement does not replace this detail optimization. (src/templates/clawhub-source.ts:393, e531410a397e)
  • Real behavior proof inspected: All four downloaded screenshots show equivalent Research monitor detail rows and nonempty SOUL.md previews; the full PR body records final-production-code Gateway measurements, response parity, and browser RPC results. (665fab132433)
  • Diff-caused test budget failure: An independent read-only LF count finds 6,473,470 tracked test lines against an effective ceiling of 6,473,428, an excess of 42; this PR adds 71 net test lines without an allocation record. (src/templates/clawhub-source.test.ts:432, 665fab132433)
  • Exact-head CI: checks-node-changed succeeds, while checks-fast-baseline-ratchets fails with a test-lines annotation. Full job-log retrieval was blocked by the Azure storage allowlist; the independently verified counter and checker source establish the repair. (scripts/check-test-lines-ratchet.mts:229, 665fab132433)
  • Required dependency contract verified: Replacing artifact resolution with release metadata relies on ClawHub's HTTP contract: both routes use the same viewer-scoped version query and toReleaseArtifact projection; toPackageVersionResponse includes that artifact. The dependency's root policy was read because the PR relies on this contract. (convex/lib/packageReadProjection.ts:114, 923099b7bb4f)

PR surface

Source +81, Tests +71, Other +91. Total +243 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 213 132 +81
Tests 2 76 5 +71
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 91 0 +91
Total 5 380 137 +243

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
Production versus test growth Production +81 net lines; tests +71 net lines. Production growth owns parallel download coordination and cleanup; tests cover concurrency, rejection before extraction, cancellation, and cleanup.

Labels

Label changes:

  • add P2: Template details incur a measurable user-facing delay with limited blast radius.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: Template details incur a measurable user-facing delay with limited blast radius.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

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.

Reviewed November 4, 2026, 9:20 PM ET / November 5, 2026, 02:20 UTC.

@Patrick-Erichsen
Patrick-Erichsen merged commit 11c8f23 into main Nov 5, 2026
148 of 152 checks passed
@Patrick-Erichsen
Patrick-Erichsen deleted the fix/templates-detail-latency-20261104 branch November 5, 2026 04:13
@Patrick-Erichsen

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 5, 2026
* fix: Template details load without serial registry waits

* test(templates): use canonical manifest in authority fixture

* test(templates): allocate owned detail regression coverage
steipete added a commit that referenced this pull request Nov 5, 2026
#193124 added scripts/bench-template-detail.mts as a standalone measurement command documented by its source header, so the full-tree unused-file scan reports it. Register it beside the other standalone benchmarks.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 6, 2026
openclaw#193124 added scripts/bench-template-detail.mts as a standalone measurement command documented by its source header, so the full-tree unused-file scan reports it. Register it beside the other standalone benchmarks.
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. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant