Skip to content

refactor(skills): run skill library import and mutations in workers (skilllib B) - #164262

Merged
steipete merged 5 commits into
mainfrom
dbasync/skilllibb
Oct 3, 2026
Merged

steipete merged 5 commits into
mainfrom
dbasync/skilllibb

Conversation

@steipete

@steipete steipete commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Skill library import, upload, and mutation requests still execute SQLite on the Gateway thread, including ownership, quota, and revision checks.

Why This Change Was Made

Extend the typed shared-state write registry and reuse skilllib A's captured physical store and selection-authority owner. Bundle preparation and immutable file publication precede synchronous worker transactions. Transactions reread ownership, revision CAS, quotas, and upload expiry; live host grants run at transaction and commit. Native receipts settle accepted work and publish selection invalidation inside the writer FIFO without replaying uncertain writes.

User Impact

No schema, retention, permission, RPC, or update behavior changes. The critical-scan publication rejection remains intact. Failed SQL retains immutable unreferenced revision files, matching the existing recovery contract. The released synchronous SDK metadata reader remains as deprecated-SDK migration debt; bundled mutation callers await the worker.

Built on merged #164165; this PR targets main after incorporating 5c5700d31f6705c08ef101171693cc555c12ecee with merge commit 84984878f44a778c728a6ec051fbf14dc1b4ded5, without rebasing. The main fix moves the shared error and session-provenance modules out of the forbidden import closures; this candidate preserves those boundaries. Adjacent overlaps: #163239 proposes removing critical-scan rejection (out of scope and preserved); #161057 extracts the scanner (incidental cleanup, minimal overlapping hunks).

Evidence

  • Production: +622 / -385 lines, net +237; 1,007 changed lines across 14 production files.
  • Native inventory with each revision's own classifications: T1 1,300 → 1,280; skill library 21 → 1. The remaining site is the released SDK metadata batch.
  • Boundary regression on skilllib A recorded 266 caller-thread SQL observations (60 mentioning library tables); candidate measured zero.
  • Original-candidate macOS proof: 107 tests passed across 13 files using pnpm test <files> --maxWorkers=1:
    • Service, selection-authority, and role suites: 39 tests, 504.45 s wall time.
    • Mutation boundary, persistence, resource/snapshot loaders, embedded readers, and Gateway/authoring callers: 68 tests, 540.84 s wall time.
    • The standalone mutation-boundary run also passed all 5 tests in 124.01 s wall time (54.76 s Vitest duration, including import/transform time). The baseline failure took 121.90 s.
      These real SQLite-worker, filesystem, concurrency, and RPC contracts require their native boundaries. Cold worker compilation and the heavily loaded host dominate the wall times. Test consumers use the existing forked database-worker lanes and join cleanup. Testbox was attempted but the final lease remained queued without a runner; no Linux result is claimed. Current-head CI completed in 8,565 aggregate job seconds (run 37120915863).
  • node scripts/check-changed.mjs --base 9da28ad4bd0ee3a9ba9757b9d6f444a6306ac3a0 passed, including core/test typechecks, full lint, unused-export scans, and repository guards. Two inherited max-lines warnings remain in untouched main files. The original merged worktree and validation candidate have identical complete Git indexes (51,990 files).
  • Madge: 0 cycles. Database-worker ratchet passed against the pinned main base. Compiled-wrapper runtime dependency inventory has no missing files. No new OPENCLAW_* names.
  • Independent Codex autoreview through P2 on the main-based candidate: scoped-clean. Subsequent edits only remove unused test imports and a redundant default type argument.
  • Released SDK inspection: v2026.9.8 (fc23bc864e4553c2d215e479eeec47b67a0bf943) exports none of the moved mutation/import APIs; synchronous skill-command discovery and harness tool-surface contracts are retained.

Existing authoring callbacks retain their placement/session authority owner (src/gateway/skill-library-authoring.ts:80-93). Standalone mixed-requester/profile and workspace-authoring checks at lines 37-41 and 143 remain separate migration debt; this PR introduces no SQL in host grant callbacks.

Landing validation

  • Original CI run 37117950722 failed two tooling jobs because this PR inserted three Gateway database-worker test paths outside canonical sorted order. Both complete files failed in all five head replays and passed in all five isolated merge-base replays (9da28ad4bd0ee3a9ba9757b9d6f444a6306ac3a0), singly with --maxWorkers=1. This was PR-caused. Commit 43cef6a03c918 fixes ordering without changing membership or assertions; both suites then passed 537 tests in 313.09 s.
  • After the main merge and import conflict repairs, 131 tests across 15 files passed in 540.29 s: test/scripts/runtime-process-build-graph.test.ts, src/auto-reply/reply/get-reply.imports.test.ts, all src/skills/library suites, workspace and embedded readers, and Gateway library/remote/authoring callers. Command: node scripts/run-vitest.mjs <those files> --maxWorkers=1. The wrapper built and verified native worker artifacts.
  • Fresh full-candidate Codex autoreview through P2 against main 5c5700d31f670: scoped-clean. Conflict resolutions retain the worker implementation and the new shared error-class identity. No old library/errors imports remain.
  • Released SDK recheck against v2026.9.8 confirms no changed mutation/import function is exported through plugin SDK or runtime contracts. Synchronous skill-command discovery and harness readers remain unchanged as deprecated-SDK debt. Critical-scan rejection remains.
  • The earlier PR-context failure was a missing template heading; the body correction passed in run 37118557985. Current-head CI run 37120915863 passed with no failed/cancelled jobs (8,565 aggregate job seconds). ClawSweeper completed review of 84984878f44a7 at 2026-10-03 11:56 UTC in run 37120979955, confirmed the prior ordering finding resolved, and reported no actionable or security findings.

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.
Reuse the shared-state writer and skill-library selection authority for synchronous worker transactions and acknowledged publication. Preserve revision CAS, quotas, upload expiry, live ownership, immutable-file recovery, and critical-scan rejection.
@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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling size: XL 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 3, 2026, 8:07 AM ET / 12:07 UTC (Revision 4).

ClawSweeper review

What this changes

Moves Skill Library saves, imports, uploads, and mutations into database workers while preserving ownership checks, revision conflicts, and publication receipts.

Merge readiness

✅ Ready for maintainer review

This remains useful work: current main still performs library mutations synchronously. The prior ordering finding is resolved, and no blocking introduced defect was found.

Priority: P2
Reviewed head: 84984878f44a778c728a6ec051fbf14dc1b4ded5

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent worker migration with relevant native-boundary evidence and no remaining actionable finding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): Reported macOS runs exercise the real library services, SQLite worker transport, and filesystem: zero caller-thread SQL, native publication refusal without a database pointer, and role/alias revocation before SQL publication. Source inspection confirms these production-boundary scenarios; this review did not rerun them. Stored schemas and serialization contracts are unchanged.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Reported macOS runs exercise the real library services, SQLite worker transport, and filesystem: zero caller-thread SQL, native publication refusal without a database pointer, and role/alias revocation before SQL publication. Source inspection confirms these production-boundary scenarios; this review did not rerun them. Stored schemas and serialization contracts are unchanged.
Evidence reviewed 8 items Pinned introduction boundary: Reviewed the introduced delta from the pinned merge base to the exact original head. The supplied GitHub test merge is stale and was not used to infer removal of current-main behavior.
Still necessary on current main: Fetched main's service still opens the database and runs publication and mutation transactions on the caller thread. The merged read migration explicitly left imports and mutations for follow-up.
Live authority and native settlement: Host admission rechecks captured physical-store identity, roles, scopes, profile, namespace, and the caller's current authority at transaction and commit. Native receipts settle accepted results; selection invalidation completes inside the writer FIFO without replaying uncertain writes.
Findings None None.
Security None None.

How this fits together

Skill Library stores reusable skills and their immutable revisions for authenticated users and teams. Gateway requests prepare files, submit database changes, and return receipts that determine future session selections.

flowchart TD
  A[Gateway library request] --> B[Capture store and live authority]
  B --> C[Prepare and publish immutable files]
  B --> D[Database worker]
  C --> D
  D --> E[Check ownership and revision]
  E --> F[Commit SQLite changes]
  F --> G[Publish selection invalidation and receipt]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +237, Tests +318, Docs +6, Other +20. Total +581 across 26 files.

View PR surface stats
Area Files Added Removed Net
Source 14 622 385 +237
Tests 10 419 101 +318
Docs 1 9 3 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 1 20 0 +20
Total 26 1070 489 +581

Review metrics

Metric Value Why it matters
Production versus test growth Production net +237 lines; tests and test support net +310 lines Production growth is explained by typed worker commands, live admission, and native receipt settlement; test growth covers concurrency and recovery boundaries.

Technical review

Best possible solution:

Keep library writes under the existing shared-state worker owner, with live admission and durable receipts preserving current library semantics.

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

Not applicable as a user-facing bug reproduction; current-main source directly establishes caller-thread SQL, and the reported native boundary measurement demonstrates the intended change.

Is this the best way to solve the issue?

Yes. Reusing the existing worker registry and selection-authority owner avoids a competing persistence path while retaining transaction checks and recovery semantics.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded runtime responsiveness improvement with preserved user-facing contracts.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): Reported macOS runs exercise the real library services, SQLite worker transport, and filesystem: zero caller-thread SQL, native publication refusal without a database pointer, and role/alias revocation before SQL publication. Source inspection confirms these production-boundary scenarios; this review did not rerun them. Stored schemas and serialization contracts are unchanged.
  • proof: sufficient: Contributor real behavior proof is sufficient. Reported macOS runs exercise the real library services, SQLite worker transport, and filesystem: zero caller-thread SQL, native publication refusal without a database pointer, and role/alias revocation before SQL publication. Source inspection confirms these production-boundary scenarios; this review did not rerun them. Stored schemas and serialization contracts are unchanged.

Evidence

What I checked:

  • Pinned introduction boundary: Reviewed the introduced delta from the pinned merge base to the exact original head. The supplied GitHub test merge is stale and was not used to infer removal of current-main behavior. (84984878f44a)
  • Still necessary on current main: Fetched main's service still opens the database and runs publication and mutation transactions on the caller thread. The merged read migration explicitly left imports and mutations for follow-up. (src/skills/library/service.ts, e8df9f33024f)
  • Live authority and native settlement: Host admission rechecks captured physical-store identity, roles, scopes, profile, namespace, and the caller's current authority at transaction and commit. Native receipts settle accepted results; selection invalidation completes inside the writer FIFO without replaying uncertain writes. (src/skills/library/store-access.ts:135, 84984878f44a)
  • Production-boundary evidence: The captured PR body reports macOS runs through real SQLite workers, files, and RPC callers: caller-thread SQL observations fell from 266 to zero, and the integrated candidate passed 131 tests. Inspected boundary scenarios exercise conflicting upload chunks, native SQL rejection, role/alias revocation after file publication, and expiry without installing a database pointer. These runs were reported by the author, not executed during this read-only review. (src/skills/library/mutations-worker.test.ts:23, 84984878f44a)
  • Preserved persistence and security contracts: Worker kernels retain existing row fields, ownership checks, revision CAS, upload limits, and expiry. File publication still precedes SQL references; critical-scan rejection and immutable unreferenced-file recovery remain. No schema, protocol, configuration, dependency, or package-resolution change is introduced. (src/skills/library/service.ts:109, 84984878f44a)
  • Previous finding resolved: GitHub's commit patch moves the three Gateway worker tests into alphabetical positions without changing membership. The pinned head retains those corrected positions, agreeing with the completed prior review. (test/vitest/vitest.gateway-server-paths.mjs:169, 43cef6a03c91)

Likely related people:

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

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-03T10:59:08.330Z sha 6bd8e99 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-03T11:11:25.161Z sha 6bd8e99 :: needs changes before merge. :: [P2] [P2] Insert the Gateway worker tests in alphabetical order
  • reviewed 2026-10-03T11:56:18.079Z sha 8498487 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added 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 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
@steipete

steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed 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. labels Oct 3, 2026
@steipete
steipete merged commit a38eefe into main Oct 3, 2026
156 checks passed
@steipete
steipete deleted the dbasync/skilllibb branch October 3, 2026 12:15
@steipete

steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 4, 2026
…skilllib B) (openclaw#164262)

* refactor(skills): move library reads and selection into workers

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.

* refactor(skills): run library imports and mutations in workers

Reuse the shared-state writer and skill-library selection authority for synchronous worker transactions and acknowledged publication. Preserve revision CAS, quotas, upload expiry, live ownership, immutable-file recovery, and critical-scan rejection.

* fix(test): keep skill library Gateway inventory in canonical order
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL 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