Skip to content

perf(catalog): cadence-proof provider caches and parallelize the Claude scan - #115259

Merged
steipete merged 1 commit into
mainfrom
perf/catalog-cadence
Jul 28, 2026
Merged

steipete merged 1 commit into
mainfrom
perf/catalog-cadence

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

After #114961, sessions.catalog.list still averaged 418ms × 60/100min on team.openclaw.ai. A deep audit found the systemic cause: every catalog cache TTL sits BELOW the actual poll cadence — which is 5s under activity (sawChange fast-follow), not 30s — so steady-state polls are always cold. The Claude memo's tree stamp was only an AND-condition with its 15s TTL (never used to revalidate an expired entry), and the scan serialized ~800 realpath+stat calls (measured 17× faster parallel). Codex's 3s page memo repaid a 256ms app-server roundtrip every poll; OpenCode spawned its CLI subprocess per poll with no cache; Pi re-walked and stat'ed its whole store per poll; the PATH-probe memo's hits didn't slide its expiry; and the gateway single-flight dropped settled results immediately, so out-of-phase clients shared nothing.

Why This Change Was Made

Caches that expire faster than their callers poll are pure overhead. The fix aligns every layer with the real cadence and replaces time-based expiry with change detection where a cheap change signal exists.

User Impact

Sidebar catalog polls drop from ~418ms to near-noise in steady state; freshness contracts are explicit and bounded (changes visible by the next 5s fast-follow tick).

Evidence

  • Claude: per-file fs work parallelized through a 32-op pool with byte charges, cache replay, and record insertion kept in raw traversal order — the 64MiB budget frontier is byte-identical warm/cold (regression: first 64 of 66 one-MiB transcripts selected despite parallel completion). Stamp is now append-aware (per-dir max child mtime) and revalidates the memo; minutes-scale hard TTL as backstop; partial scans retry after 15s; Desktop metadata bounded at 60s; forceRefresh bypasses everything.
  • Codex: 32s page memo; passive refresh failures serve the last real page and retry next poll. Codex source inspected at 15d7d2a7337: codex-rs/app-server/src/request_processors/thread_processor.rs:1981,:4167, thread-store/src/local/list_threads.rs:22,:151 (thread/list walks the store/state DB before status projection — the roundtrip is real work worth caching).
  • OpenCode: 32s memo keyed by config identity + CLI env + SQL (was: subprocess spawn per poll); continuation checks bypass.
  • Pi: 32s candidate snapshot keyed by session/ACP roots.
  • PATH probes: sliding 60s expiry on hits and misses; config reload clears; install/removal observed after reload or 60s idle (documented).
  • Gateway: settled results shared for 3s (below the 5s fast-follow, so changed worlds appear within one fast tick); registration sorting cached on registry identity.
  • Validation: 231 focused tests; full lint, both deadcode lanes, core+UI+extension tsgo, format, git diff --check clean; autoreview clean.

@steipete
steipete marked this pull request as ready for review July 28, 2026 15:16
@steipete
steipete merged commit 9ae79ee into main Jul 28, 2026
176 of 191 checks passed
@steipete
steipete deleted the perf/catalog-cadence branch July 28, 2026 15:37
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Jul 28, 2026
…-20260728

* origin/main:
  fix(ci): bound Telegram Mantis proof cleanup (#115253)
  fix(scripts): materialize PR worktrees before gates (#115120)
  perf(catalog): cadence-proof provider caches and parallelize the Claude scan (#115259)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 29, 2026
steipete added a commit that referenced this pull request Oct 14, 2026
…le B) (#171920)

* fix(google): report the operation that supplied fallback video

An empty SDK video result can fall back to a distinct REST operation. Capture
its name after that fallback so returned metadata identifies the delivered video.
Keep the SDK error check before fallback and preserve requests and media limits.

Parameterize the existing fallback regression for SDK 404 and SDK empty results.
The real provider entry probe fails on the original empty-result metadata and
passes both scenarios with this fix, using synthetic SDK and HTTP responses.

* refactor(providers): consolidate old provider and protocol helpers

Share exact Gateway schema fields without changing public shapes. Consolidate
tool-payload classification, catalog responses, device polling, media formatting,
and speech format selection. Remove the Mantle factory's test-only injection seam.

Best-effort tradeoffs accepted:
- OpenRouter equivalent nested request policies reordered during configuration
  edits may cause another bounded catalog GET. #102062 supplies synthetic key
  equivalence, not a human incident; full auth/network policy stays in the key.
- Warm Anthropic scans may discover more history than cold scans. #109309/#115259
  establish synthetic frontier equality, not a human pagination incident. Charge
  actual I/O only, retaining the 64MiB read and bounded file/cache limits.
- A complete Anthropic read exactly at the I/O cap can now be cached. The former
  fence supported synthetic cold/warm cost equality; incomplete reads stay out.
- Deleted transcript metadata can remain in the bounded cache until eviction.
  #109309's eager sweeps duplicate current-candidate visibility and bounded
  retention; no current file means no visible cached row.
- A manually sparse single-audio-item array yields empty text rather than an
  invariant error. #104577/#104558 introduced the throw for a compiler ratchet;
  the real caller supplies a dense filter result, not a reported runtime failure.

Standalone session-memory backend and its registry/factory/tests are untouched.

* refactor(qa-lab): consolidate older harness paths

Share manifest discovery/linking, bus parser construction, Matrix device
verification, registration-local fault history, FIFO starts and mock answers.
Remove type-laundering and duplicate work on trusted internal facts.

Best-effort tradeoffs accepted

- Heap-capture PID fences came from synthetic replacement tests in #137860,
  not a human actual-use report. A coincident restart may fail or omit this
  optional diagnostic; the snapshot-writer health barrier remains.
- Failed-realpath lexical guessing came from synthetic execution validation
  in #116912. A disappearing/inaccessible test now fails existing evidence
  verification instead of guessing its identity; real symlink paths still work.
- #143976 introduced duplicate taxonomy parsing alongside both production
  callers' canonical identity guarantees. Untyped invalid internal build calls
  omitting required identity are unsupported; external artifact validation stays.
- Manifest discovery is invocation-local. A source catalog changed during
  staging is best-effort and is rescanned on the next invocation, rather than
  repeatedly scanning the same catalog for each selected plugin.
- The search fixture's fixed hostname (8288b4d) needs no URL-parser fallback.
  No runtime hostname input exists; a future fixture URL rewrite must update
  its hostname field too. Current output is unchanged.
- db4ad84 projected hit objects to hide registration IDs. Those IDs are now
  gone, and all private callers only read hit facts. Unexpected future internal
  object mutation may alter QA diagnostics; stable array snapshots remain.

Focused owner tests, canonical QA production/test typechecks, syntax lint,
formatting, suppression tests, zero runtime/madge cycles and independent
P0-P2 review cover the retained cut. No SDK/config/protocol/schema changes.

Local broad-proof gaps are recorded in .local/q04-ledger.md: SDK boundary
declaration preparation exceeded its existing 300000ms deadline before typed
lint ran; the repo-wide SQLite worker scanner was interrupted after more than
25 minutes on an overloaded host. Neither is attributed as inherited CI red.
The production, full-tree and script Knip scans also exceeded their existing
600-605s deadlines without a code verdict. Bundled exact-head CI must provide
the missing broad proof; no timeout/skip/retry policy was changed.

* refactor(android): simplify legacy native owners

Use platform accessibility nodes and canonical coroutine cancellation. Remove duplicate sheet validation and unreachable mascot clamps while retaining security, resource bounds and normal lifecycle behavior.

Fix DNS-SD display names by preserving advertised UTF-8 text and decoding instance names once. Both Android APK variants, 260 focused native test cases, lint, cycle checks and independent review validate the candidate.

* refactor: keep round-3 bundle within old-code scope

Drop all hunks in files touched on main within seven days, plus dependent Mantle, Anthropic cache, and QA assertion cuts. Preserve current main tests and baseline without allowances or shims. Keep Google SDK errors in the typed SDK owner and REST errors in its existing helper, without adding assertions. Retain one full mock ask-user roundtrip contract and the two distinct precedence cases.

* refactor(anthropic): preserve fresh hosts without map spread

* refactor(qa-lab): drop Gateway startup cleanup from bundle

Restore the q04 startup import closure and direct tests to main for Telegram menu E2E attribution. Keep Matrix/profile-evidence, provider, and Android changes unchanged.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 15, 2026
…le B) (openclaw#171920)

* fix(google): report the operation that supplied fallback video

An empty SDK video result can fall back to a distinct REST operation. Capture
its name after that fallback so returned metadata identifies the delivered video.
Keep the SDK error check before fallback and preserve requests and media limits.

Parameterize the existing fallback regression for SDK 404 and SDK empty results.
The real provider entry probe fails on the original empty-result metadata and
passes both scenarios with this fix, using synthetic SDK and HTTP responses.

* refactor(providers): consolidate old provider and protocol helpers

Share exact Gateway schema fields without changing public shapes. Consolidate
tool-payload classification, catalog responses, device polling, media formatting,
and speech format selection. Remove the Mantle factory's test-only injection seam.

Best-effort tradeoffs accepted:
- OpenRouter equivalent nested request policies reordered during configuration
  edits may cause another bounded catalog GET. openclaw#102062 supplies synthetic key
  equivalence, not a human incident; full auth/network policy stays in the key.
- Warm Anthropic scans may discover more history than cold scans. openclaw#109309/openclaw#115259
  establish synthetic frontier equality, not a human pagination incident. Charge
  actual I/O only, retaining the 64MiB read and bounded file/cache limits.
- A complete Anthropic read exactly at the I/O cap can now be cached. The former
  fence supported synthetic cold/warm cost equality; incomplete reads stay out.
- Deleted transcript metadata can remain in the bounded cache until eviction.
  openclaw#109309's eager sweeps duplicate current-candidate visibility and bounded
  retention; no current file means no visible cached row.
- A manually sparse single-audio-item array yields empty text rather than an
  invariant error. openclaw#104577/openclaw#104558 introduced the throw for a compiler ratchet;
  the real caller supplies a dense filter result, not a reported runtime failure.

Standalone session-memory backend and its registry/factory/tests are untouched.

* refactor(qa-lab): consolidate older harness paths

Share manifest discovery/linking, bus parser construction, Matrix device
verification, registration-local fault history, FIFO starts and mock answers.
Remove type-laundering and duplicate work on trusted internal facts.

Best-effort tradeoffs accepted

- Heap-capture PID fences came from synthetic replacement tests in openclaw#137860,
  not a human actual-use report. A coincident restart may fail or omit this
  optional diagnostic; the snapshot-writer health barrier remains.
- Failed-realpath lexical guessing came from synthetic execution validation
  in openclaw#116912. A disappearing/inaccessible test now fails existing evidence
  verification instead of guessing its identity; real symlink paths still work.
- openclaw#143976 introduced duplicate taxonomy parsing alongside both production
  callers' canonical identity guarantees. Untyped invalid internal build calls
  omitting required identity are unsupported; external artifact validation stays.
- Manifest discovery is invocation-local. A source catalog changed during
  staging is best-effort and is rescanned on the next invocation, rather than
  repeatedly scanning the same catalog for each selected plugin.
- The search fixture's fixed hostname (34f2850) needs no URL-parser fallback.
  No runtime hostname input exists; a future fixture URL rewrite must update
  its hostname field too. Current output is unchanged.
- 2f4f28f projected hit objects to hide registration IDs. Those IDs are now
  gone, and all private callers only read hit facts. Unexpected future internal
  object mutation may alter QA diagnostics; stable array snapshots remain.

Focused owner tests, canonical QA production/test typechecks, syntax lint,
formatting, suppression tests, zero runtime/madge cycles and independent
P0-P2 review cover the retained cut. No SDK/config/protocol/schema changes.

Local broad-proof gaps are recorded in .local/q04-ledger.md: SDK boundary
declaration preparation exceeded its existing 300000ms deadline before typed
lint ran; the repo-wide SQLite worker scanner was interrupted after more than
25 minutes on an overloaded host. Neither is attributed as inherited CI red.
The production, full-tree and script Knip scans also exceeded their existing
600-605s deadlines without a code verdict. Bundled exact-head CI must provide
the missing broad proof; no timeout/skip/retry policy was changed.

* refactor(android): simplify legacy native owners

Use platform accessibility nodes and canonical coroutine cancellation. Remove duplicate sheet validation and unreachable mascot clamps while retaining security, resource bounds and normal lifecycle behavior.

Fix DNS-SD display names by preserving advertised UTF-8 text and decoding instance names once. Both Android APK variants, 260 focused native test cases, lint, cycle checks and independent review validate the candidate.

* refactor: keep round-3 bundle within old-code scope

Drop all hunks in files touched on main within seven days, plus dependent Mantle, Anthropic cache, and QA assertion cuts. Preserve current main tests and baseline without allowances or shims. Keep Google SDK errors in the typed SDK owner and REST errors in its existing helper, without adding assertions. Retain one full mock ask-user roundtrip contract and the two distinct precedence cases.

* refactor(anthropic): preserve fresh hosts without map spread

* refactor(qa-lab): drop Gateway startup cleanup from bundle

Restore the q04 startup import closure and direct tests to main for Telegram menu E2E attribution. Keep Matrix/profile-evidence, provider, and Android changes unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant