Repository navigation
perf(skills): project the skill library once per catalog instead of four reads per entry - #165106
Conversation
Select profile metadata from admitted schema facts so separate read-only handles use the narrow cached query instead of copying avatar BLOBs. Share the existing fact-keyed role detector with display and avatar reads. Keep historical role-absent tables, one-hop merges, live role revocation, and malformed non-BLOB conversion behavior. Unadmitted display handles still need the column probe; authorizer-controlled ensured writers need the existing ensure fallback to avoid probes and unrelated denied columns. Preserving those contracts requires +21/-11 production LOC, net +10. The admitted-reader regression returns zero avatar bytes instead of 655360 across two three-entry lists, with 26 profile statements unchanged. Both focused suites pass: 27 profile tests and 13 library authority tests.
…ete/sqlite-skill-library-projection
Resolve actor authority once per catalog, join revision descriptions, and prepare bounded owner metadata through the existing profile owner. Reuse one catalog for scoped display and session attachment while preserving worker snapshots and host authority readback. Restore enabled-only SQL selection for new-session seeds (Related: #164165). The 100-entry probe drops from 404 to 5 native calls and from 8,273,920 avatar bytes to zero. Disabled-only seeds no longer project disabled rows. The combined +41 production-line delta, including the profile-metadata prerequisite, is accepted by the coordinator as a LOC-positive exception.
|
🦞👀 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 maintainer review before merge. Reviewed October 4, 2026, 4:56 PM ET / 20:56 UTC. ClawSweeper reviewWhat this changesThe PR batches skill-library ownership and revision reads, avoids copying profile avatars, reuses one catalog for session browsing, and excludes disabled skills from default-seed queries. Merge readiness✅ Ready for maintainer review This PR remains useful: current main still performs per-entry projection reads. No actionable correctness or security defect was found in the introduced changes. Priority: P2 Review scores
Verification
How this fits togetherThe skill library stores personal and shared skills with immutable revisions. Gateway requests and new-session admission read this library through SQLite workers to produce visible catalogs and session selections. flowchart TD
A[Gateway request or new session] --> B[Captured operator authority]
B --> C[SQLite worker snapshot]
C --> D[Skills and revision metadata]
C --> E[Batched profile metadata]
D --> F[Authorized catalog or enabled seeds]
E --> F
F --> G[Host authority revalidation]
G --> H[Library response or session selections]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +41, Tests +296, Other 0. Total +337 across 9 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep catalog preparation within the existing worker and profile owners, preserving session revision pins and live authority checks. Do we have a high-confidence way to reproduce the issue? Yes, source inspection establishes repeated per-entry reads on current main, and the PR supplies focused SQLite counter regressions. This reviewer did not execute the probes. Is this the best way to solve the issue? Yes, batching through the existing store and profile owners is a focused solution that preserves revision selection, alias semantics, and host revalidation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 97a770b1a7ef. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash auto-merge.
|
…our reads per entry (openclaw#165106) * perf(state): read user profile metadata without copying avatar bytes Select profile metadata from admitted schema facts so separate read-only handles use the narrow cached query instead of copying avatar BLOBs. Share the existing fact-keyed role detector with display and avatar reads. Keep historical role-absent tables, one-hop merges, live role revocation, and malformed non-BLOB conversion behavior. Unadmitted display handles still need the column probe; authorizer-controlled ensured writers need the existing ensure fallback to avoid probes and unrelated denied columns. Preserving those contracts requires +21/-11 production LOC, net +10. The admitted-reader regression returns zero avatar bytes instead of 655360 across two three-entry lists, with 26 profile statements unchanged. Both focused suites pass: 27 profile tests and 13 library authority tests. * perf(skills): batch library catalog projections Resolve actor authority once per catalog, join revision descriptions, and prepare bounded owner metadata through the existing profile owner. Reuse one catalog for scoped display and session attachment while preserving worker snapshots and host authority readback. Restore enabled-only SQL selection for new-session seeds (Related: openclaw#164165). The 100-entry probe drops from 404 to 5 native calls and from 8,273,920 avatar bytes to zero. Disabled-only seeds no longer project disabled rows. The combined +41 production-line delta, including the profile-metadata prerequisite, is accepted by the coordinator as a LOC-positive exception.
What Problem This Solves
Large skill libraries repeat actor, owner, and revision reads for every entry; new-session seeding also projects disabled skills before discarding them.
Related: #164165
User Impact
Library lists and new-session defaults avoid repeated SQLite calls and avatar copying. Disabled skills remain visible and explicitly attachable, but are excluded from default-seed SQL selection. Ownership, role ceilings, selected revisions, and the 64-skill selection limit are preserved. No schema, retention, configuration, or update migration changes.
Why This Change Was Made
Resolve the actor once inside the existing worker snapshot, join revision descriptions, and prepare owner metadata in bounded 500-ID cohorts using the existing profile owner. Catalog and exact reads share one prepared projection. Scoped display and session attachable entries reuse one catalog, with host authority rechecked after awaits.
This also restores the enabled-only seed selection lost in #164165. The older wide-profile fallback predates that PR. The supplied profile-metadata prerequisite is included here; legacy optional-column and malformed-value behavior remains intact. One consolidation pass folded the shared list projection into the existing store owner and removed the extra file.
Evidence
Production LOC: +202/-161 (net +41), accepted by the coordinator as a LOC-positive exception
Tests: +301/-5 (net +296). Counts use the branch merge base; unrelated changes from concurrently advancing
origin/mainare excluded.The 2026-10-04 read-only measurements of team.openclaw.ai, label
user_profiles, show 5.9 MiB for 75 rows, approximately 80 KiB per row. Production skill cardinality and list frequency were not supplied, and no specific slow-hold label was recorded for this path.The final 501-owner catalog, including merged aliases, missing profiles, and missing merge targets, takes 7 native calls. Its disabled-only seed takes 3 calls and returns zero pins, while general listing still returns all 501 entries. Counts include one freshness probe. Work scales with owner/alias cohorts; these component counts and transient bytes copied are not end-to-end timing or retained-leak claims. The supplied earlier 64-entry probe independently recorded 260 calls and 5,324,800 avatar bytes.
The regression failed on the original path, then passed after the change. The final counter case takes 1.218 seconds of test time. Existing worker-boundary cases retain no-host-SQL and live-authority revocation proof. The Gateway case verifies one catalog read for scoped display and attachable entries; the large-catalog fixture verifies that narrowing to “mine” clears an inapplicable limit notice.
All commands below used an isolated
TMPDIRand--maxWorkers=1:pnpm test src/skills/library/service.test.ts --maxWorkers=1pnpm test src/skills/library/selection-authority.test.ts --maxWorkers=1pnpm test src/skills/library/service-roles.test.ts --maxWorkers=1pnpm test src/skills/library/mutations-worker.test.ts --maxWorkers=1pnpm test src/skills/library/persistence.test.ts --maxWorkers=1pnpm test src/state/user-profiles.test.ts --maxWorkers=1pnpm test src/gateway/server-methods/skills-library.test.ts --maxWorkers=1The service and persistence suites exercise real worker publication, retained files, and process lifetimes; their duration includes that boundary proof and test-worker setup. Unchanged role, mutation, persistence, and profile proof was reused after the pure list-projection consolidation. CI seconds are not yet available; this PR's first run will provide them.
Formatting, scoped oxlint,
git diff --check,pnpm check:assertion-safety,pnpm check:max-lines-ratchet,pnpm check:line-cap-ratchet, andpnpm check:database-worker-ratchetpassed. The worker inventory follows the renamed selector; SQL remains in its existing worker. Codex autoreview: scoped-clean at P2, first round, no accepted/actionable findings.