Repository navigation
refactor(skills): run skill library reads and selection authority in workers (skilllib A) - #164165
Conversation
Bind prepared selections to current library and profile authority across admission waits, including rollback and unknown native commit outcomes. Preserve private revision disclosure and worker error identity. Native import and mutations remain for the follow-up; retain the shipped synchronous SDK readers.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
|
|
Codex review: needs maintainer review before merge. Reviewed October 3, 2026, 5:00 AM ET / 09:00 UTC (Revision 3). ClawSweeper reviewWhat this changesThe PR moves personal skill-library browsing and selection preparation into database workers while preserving authorization checks across waits and existing session access to pinned revisions. Merge readiness✅ Ready for maintainer review Keep open: current main still needs this cutover. The prior integration blocker is resolved, and this review found no concrete introduced correctness or security defect. Priority: P2 Review scores
Verification
How this fits togetherThe skill library stores reusable instructions owned by Gateway profiles. Gateway requests browse those instructions or select revisions for sessions, which then supply them to agent execution. flowchart TD
A[Gateway request] --> C[Library read worker]
B[Existing SQLite library] --> C
C --> D[Current profile and library authority]
D --> E[Session admission]
E --> F[Committed revision pins]
D --> G[Authorized instruction reads]
F --> H[Agent skill runtime]
G --> H
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +433, Tests +280, Docs +12, Other +2. Total +727 across 43 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Use the existing shared-state worker for library reads and owner-held revocation facts at session commit, preserving immutable session pins and released synchronous SDK contracts. Do we have a high-confidence way to reproduce the issue? Not applicable as a refactor; current-main source establishes the synchronous library-read paths being migrated, and reported focused checks exercise the changed ownership boundaries. Is this the best way to solve the issue? Yes: extending the existing worker registry and retaining synchronous commit assertions preserves one database owner and the released caller contracts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c2a46deeea81. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
Resolve additive read-registry and error-transport conflicts while retaining both secret-store and skill-library variants. Preserve main environment budget and critical-scan publication rejection. Mechanical integration retains the coordinator-approved P2 review at df71456; affected suites are being rerun before publication.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
Restore the worker and inline-actions import boundaries after #164165 by moving SkillLibraryError and the dependency-free session-creation provenance module to shared leaf locations. Update every importer without compatibility re-exports, preserving error-class identity and session-creation semantics. Keep the original graph assertions intact. The worker error transport, library reads and prepared selection, creator policy, and resource delivery proofs pass with no production or test LOC growth.
…claw#164165) Bind prepared selections to current library and profile authority across admission waits, including rollback and unknown native commit outcomes. Preserve private revision disclosure and worker error identity. Native import and mutations remain for the follow-up; retain the shipped synchronous SDK readers.
Restore the worker and inline-actions import boundaries after openclaw#164165 by moving SkillLibraryError and the dependency-free session-creation provenance module to shared leaf locations. Update every importer without compatibility re-exports, preserving error-class identity and session-creation semantics. Keep the original graph assertions intact. The worker error transport, library reads and prepared selection, creator policy, and resource delivery proofs pass with no production or test LOC growth.
…our reads per entry (#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: #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.
…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
Personal-library browsing, revision reads, and fresh-session/activation selection performed SQLite work on the Gateway thread. Prepared selections also reread eligibility synchronously while session admission was waiting on other owners.
Solution
Use typed commands in the existing shared-state read registry. Capture the physical store before waits, resolve profile/role/alias dependencies in the worker, and qualify returned facts through the profile owner and library writer's revision. Native writers publish that revision at commit; confirmed rollback preserves it, while an unusable transaction with an unknown commit outcome revokes old grants. Prepared pin contents are bound as well as their eligibility.
Propagate asynchronous preparation through Gateway ingress and authoring, status, embedded skill preparation, and sandbox synchronization. Preserve
SkillLibraryErrorclass identity, code, and revision across worker transport. The shared error-transport conflict with main was resolved by retaining both Goal-operation and library variants.Impact
No schema, stored-format, retention, user-configuration, or update-behavior change. Main's critical-scan publication rejection remains unchanged. Import, upload, and mutation execution remain native for the next mutations PR. The shipped v2026.9.8 synchronous command-discovery and harness tool-surface SDK contracts retain their native metadata reader.
The added code carries typed results and revocable authority across waits. Production change: +791 / -356, net +435; 1,147 changed lines, excluding tests/docs and including the wrapper dependency inventory. The environment-name budget is reduced from 477 to the exact 476 names remaining after main's cleanup; this change introduces zero new
OPENCLAW_*names.Overlap: #163239 changes publication scan policy; its semantic change is untouched and it will need to rebase. #161057 extracts scanner helpers; this PR preserves main's current scanner implementation.
Evidence
7d2e0fded0ad4ae04770c8d1b587e39f0fa18fd6.node scripts/worktree-setup.mjs gateway: passed on the integrated source; build phases took 2m40s.pnpm testwith--maxWorkers=1: selection-authority, service, and shared worker-error transport files — 95 passed, 239.59s wall after main integration.pnpm test src/gateway/server.chat-goal.test.ts --maxWorkers=1 -t 'reservation is': 2 passed, 146.80s wall after integration; verifies expiry and successor reservations across the new wait.node scripts/check-changed.mjs --base 7d2e0fded0ad4ae04770c8d1b587e39f0fa18fd6: passed, including core/test typechecks, lint, unused exports, wrapper, schema, and storage guards.Integration status
Merged main
c0c8363730facee6e6df6ee159e60f3e0e9e4fd9into the reviewed branch with merge commit928296de13787d14a019857827ed231b1beb9904(no rebase). The three conflicts were mechanical: retain both secret-store and skill-library registry/error variants, and retain main's environment-budget explanation at 476. Critical-scan publication rejection remains intact. Coordinator approval and the clean P2 autoreview atdf714569cover the unchanged product delta; the integration did not add a semantic change.Integrated focused proof:
node scripts/run-vitest.mjs src/skills/library/selection-authority.test.ts src/skills/library/service.test.ts src/state/openclaw-state-worker-error.test.ts src/state/openclaw-state-worker-error.metadata.test.ts --maxWorkers=1passed all 95 tests, 713.51s total runner wall time, including worker compilation. The environment-name check passed 476/476; this PR adds zero names. Conflict-file formatting andgit diff --checkpassed.Released SDK signatures were rechecked against latest local release
v2026.9.8: changed async preparation helpers are internal. Released synchronous command-discovery exports and harnesscreateToolSurfacestill reach the unchanged synchronousloadSkillLibrarySelectioncontract, so this change needs no new compatibility adapter.Retained host-read follow-up debt:
src/gateway/server-methods/skills-library.ts:95(session mutation authorization),:97(exact session identity/ownership), andsrc/gateway/skill-library-authoring.ts:143(workspace administrator guard). Requester invalidation also retains profile resolution atsrc/gateway/skill-library-authoring.ts:40, outside the commit guard. Selection preparation awaits before transaction admission, the existing guarded native mutation path remains, and the new prepared library/profile revision assertions add no SQL inside commit callbacks. This read cutover does not claim to migrate those mutation owners.Final focused integration proof:
node scripts/run-vitest.mjs src/gateway/server.chat-goal.test.ts test/scripts/eager-import-closure.test.ts --maxWorkers=1 -t 'reservation is|PR wrapper inventory'passed both Goal reservation cases and the wrapper dependency inventory (3 selected tests, 37 intentionally filtered cases; 433.47s wall). No failing local tests or retries occurred.