Skip to content

refactor(skills): run skill library reads and selection authority in workers (skilllib A) - #164165

Merged
steipete merged 2 commits into
mainfrom
dbasync/skilllib2
Oct 3, 2026
Merged

steipete merged 2 commits into
mainfrom
dbasync/skilllib2

Conversation

@steipete

@steipete steipete commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

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 SkillLibraryError class 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

  • Pinned main integration/base: 7d2e0fded0ad4ae04770c8d1b587e39f0fa18fd6.
  • node scripts/worktree-setup.mjs gateway: passed on the integrated source; build phases took 2m40s.
  • pnpm test with --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.
  • Retained caller/embedded proof before the mechanical main integration: 54 passed, 411.83s wall. Earlier broader Gateway coverage also passed authoring, retained-file RPC, remote skills, paired-node, and full Goal-admission cases.
  • The selection-authority file passed standalone with 12 cases, 221.01s wall. It proves zero caller-thread SQL, revocation after library/role/alias changes, exact pin binding, missing-store behavior, confirmed rollback, and unknown-commit invalidation. The unknown-commit regression failed before the fence fix. The SQL measurement stops the fixture's independent WAL timer; the assertion still rejects every caller-thread statement.
  • Timings include worker compilation and Gateway startup. These cases exercise real SQLite, worker transport, and admission ownership. CI duration is not yet available at publication.
  • node scripts/check-changed.mjs --base 7d2e0fded0ad4ae04770c8d1b587e39f0fa18fd6: passed, including core/test typechecks, lint, unused exports, wrapper, schema, and storage guards.
  • Madge: 0 cycles. Database-worker ratchet: passed; T1 1,333 → 1,330. Mixed native mutation and SDK sites remain counted.
  • Released-SDK check: v2026.9.8 exports and caller chain inspected; synchronous public contracts remain intact.
  • Independent Codex autoreview through P2, pinned to the merge base: no actionable findings. Final lint-only edits add braces, consolidate an import, and name the captured options locally.

Integration status

Merged main c0c8363730facee6e6df6ee159e60f3e0e9e4fd9 into the reviewed branch with merge commit 928296de13787d14a019857827ed231b1beb9904 (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 at df714569 cover 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=1 passed 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 and git diff --check passed.

Released SDK signatures were rechecked against latest local release v2026.9.8: changed async preparation helpers are internal. Released synchronous command-discovery exports and harness createToolSurface still reach the unchanged synchronous loadSkillLibrarySelection contract, 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), and src/gateway/skill-library-authoring.ts:143 (workspace administrator guard). Requester invalidation also retains profile resolution at src/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.

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.
@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 in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 928296de13787d14a019857827ed231b1beb9904
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/skill-library-authoring.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@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, 5:00 AM ET / 09:00 UTC (Revision 3).

ClawSweeper review

What this changes

The 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
Reviewed head: 928296de13787d14a019857827ed231b1beb9904

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent internal refactor with meaningful ownership regressions and reported integrated validation; no actionable patch defect remains.
Proof confidence 🌊 off-meta tidepool Not applicable: The ordinary external-contributor proof gate is exempt under the verified repository-admin context. Reported integrated SQLite, worker-transport and Gateway-admission checks support the changed owners and revocation behavior; this reviewer did not execute them. No unresolved material authority case or stored-data contract change was established.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The ordinary external-contributor proof gate is exempt under the verified repository-admin context. Reported integrated SQLite, worker-transport and Gateway-admission checks support the changed owners and revocation behavior; this reviewer did not execute them. No unresolved material authority case or stored-data contract change was established.
Evidence reviewed 10 items Pinned introduced change: Reviewed the c0c8363..928296d introduced delta. Raw commit records confirm that the checkout is the original PR head, with df71456 and c0c8363 as its recorded parents; the supplied stale test merge was not used to infer removal of main behavior.
Authority survives worker waits: The access owner captures the physical database, role configuration and scopes, then binds worker-reported profile dependencies and checks the library writer revision before returning prepared facts. Activation carries the prepared assertion into the session writer's synchronous pre-write guard.
Commit and rollback fencing: Native library mutations stage pending authority, publish a new revision after commit, preserve eligibility after confirmed rollback, and revoke earlier grants when the transaction outcome is unusable. Existing session pins deliberately retain their prior access contract.
Findings None None.
Security None None.

How this fits together

The 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
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +433, Tests +280, Docs +12, Other +2. Total +727 across 43 files.

View PR surface stats
Area Files Added Removed Net
Source 28 789 356 +433
Tests 12 477 197 +280
Docs 1 12 0 +12
Config 0 0 0 0
Generated 0 0 0 0
Other 2 2 0 +2
Total 43 1280 553 +727

Review metrics

Metric Value Why it matters
Production versus test growth production +791/-356; tests and support +477/-197 Production growth is explained by typed worker queries and revocable prepared authority; tests cover the corresponding ownership and transaction invariants.

Technical review

Best 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.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded internal database-threading improvement without evidence of an urgent user-facing regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The ordinary external-contributor proof gate is exempt under the verified repository-admin context. Reported integrated SQLite, worker-transport and Gateway-admission checks support the changed owners and revocation behavior; this reviewer did not execute them. No unresolved material authority case or stored-data contract change was established.

Evidence

What I checked:

  • Pinned introduced change: Reviewed the c0c8363..928296d introduced delta. Raw commit records confirm that the checkout is the original PR head, with df71456 and c0c8363 as its recorded parents; the supplied stale test merge was not used to infer removal of main behavior. (928296de1378)
  • Authority survives worker waits: The access owner captures the physical database, role configuration and scopes, then binds worker-reported profile dependencies and checks the library writer revision before returning prepared facts. Activation carries the prepared assertion into the session writer's synchronous pre-write guard. (src/skills/library/store-access.ts:58, 928296de1378)
  • Commit and rollback fencing: Native library mutations stage pending authority, publish a new revision after commit, preserve eligibility after confirmed rollback, and revoke earlier grants when the transaction outcome is unusable. Existing session pins deliberately retain their prior access contract. (src/skills/library/store-authority.ts:56, 928296de1378)
  • Integrated regression evidence: The captured PR body reports 95 passing integrated library and worker-error tests and three selected Goal-reservation/wrapper tests. Inspected regressions exercise real SQLite and worker reads, role/alias/library revocation, exact pin binding, rollback and uncertain commit outcomes; Goal cases verify no session or dispatch after reservation expiry or replacement. These are contributor-reported results; this read-only review did not execute tests. (src/skills/library/selection-authority.test.ts:108, 928296de1378)
  • Previous blocker resolved: The earlier registry was inspected through GitHub at df71456. The integrated registry retains both secret-store and skill-library operations, and error transport retains secret-store, Goal-operation and skill-library identities. The captured body supplies affected-head validation requested by the previous review. (src/state/openclaw-state-read-operation-registry.ts:11, 928296de1378)
  • Released synchronous contract retained: Inspected v2026.9.8 selection source and current synchronous command-discovery and OpenClaw harness tool-surface callers. The synchronous loadSkillLibrarySelection reader remains available; changed preparation helpers are internal. No schema, serialized format, configuration or dependency change appears in the introduced delta. (src/skills/library/selection.ts:116, fc23bc864e45)

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 (2 earlier review cycles)
  • reviewed 2026-10-03T08:15:13.497Z sha df71456 :: needs changes before merge. :: none
  • reviewed 2026-10-03T08:24:34.457Z sha df71456 :: needs changes before merge. :: none

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.
@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:

@steipete
steipete merged commit a06f24e into main Oct 3, 2026
140 checks passed
@steipete
steipete deleted the dbasync/skilllib2 branch October 3, 2026 09:29
@steipete

steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Oct 3, 2026
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.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 4, 2026
…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.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 4, 2026
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.
steipete added a commit that referenced this pull request Oct 4, 2026
…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.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 5, 2026
…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.
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. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts security-sensitive-changed 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