Skip to content

refactor(skills): prepare embedded library entries asynchronously - #148679

Merged
steipete merged 1 commit into
mainfrom
codex/embedded-library-1cd-20260914
Sep 21, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/embedded-library-1cd-20260914

Conversation

@steipete

@steipete steipete commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Rebuilding embedded or CLI skill entries reads pinned Library metadata synchronously on the Gateway thread and can publish a workspace-only cache before Library preparation succeeds.

User Impact

Skill entry preparation keeps pinned revisions, duplicate ordering, workspace filtering, and sandbox-only isolation while moving Library metadata reads to the shared reader worker. Failed or obsolete preparation cannot publish partial entries. No configuration or data migration is required.

Why This Change Was Made

The lazy Getter captures Library pin values and state admission before workspace preparation can yield, using the capture and preparation owners landed in #148560. It publishes combined entries only after both stages and current-owner checks finish. Workspace source changes retry the unfinished load; completed results stay stable, and concurrent loads retain the first complete publication.

The shared reader remains the owner of lifecycle, admission, error-phase, and retained cleanup; the carry preserves those current-main contracts. Workspace plugin discovery keeps its existing metadata path; this change does not claim that all skill discovery is SQL-free.

Evidence

The original qualified candidate 9d8ab6e19fa7fb134433360c0694d0617dbb45ad passed 225 selected tests, the full selected static gate, independent P0–P2 review, a normal build, and cold compiled Node/Bun proof. Its four fresh readers positively calibrated construction plus seven SQLite methods, then recorded zero through imports, Getter calls and close while preserving exact entries, duplicate order, lazy caching and workspace-only isolation. Those full build/runtime receipts remain pinned to that original candidate.

The current carry 7d4cd6e8796bb658a7640fce3cabcc36b4f5c141 is based on actual main 7c7c148cac3f45dcdc6601f0bdfd72289ef57e6c. Its stable patch ID is identical to the original, and the Getter production file and both changed test files are byte-for-byte unchanged. The existing P2 review is reused for that unchanged patch. Fresh qualification passed 99 tests across seven files covering the Getter, Library resources, shared-reader cleanup, snapshot admission and session-snapshot preparation, plus production types and the affected state-logging/services test-type graphs. Formatting and diff checks also passed.

The previous public-head CI run failed in Discord pacing. Actual main now includes 761725d03f294aaddc399a759a0755d34a0e1ecf, which fixes premature fixture readiness by waiting for encoded audio consumption. The controlled regression proves that premature-readiness defect; it does not establish the cause of the historical hosted pacing failure. This carry includes the landed repair and preserves current main's Shared/Flow/Projection and snapshot owners; the old CI run was not retried. The current carry has not been rebuilt or rerun through the compiled harness, and the older runtime proof is not presented as fresh current-main qualification.

Exact-head CI run 35607177457 passed. Native landing remains pending. No visual UI change, new configuration, schema, durability, retention, permission or dependency change is introduced by this Getter patch.

Changed-test cost

Measured once per changed file on 7d4cd6e8796bb658a7640fce3cabcc36b4f5c141 with pnpm test <file> --maxWorkers=1:

Changed test file Passed Local command wall Vitest elapsed Sum of reported case times
src/skills/runtime/embedded-run-entries.test.ts 15 140.85 s 121.80 s 0.153 s
src/skills/runtime/embedded-run-entries.library-read.test.ts 5 66.20 s 56.68 s 4.755 s

These are separate fresh test-process invocations on the previously qualified checkout with existing dependencies and compiler artifacts, not clean-cache benchmarks. The first invocation reported a compiler-cache hit and 34.398 seconds of preparation; its Vitest time was 91% transformation. The second reported 86% transformation. Command wall includes wrapper preparation and teardown; source hashing is excluded. All 47,655 tracked-source fingerprints, HEAD and tree matched before and after both runs.

The long wall time is dominated by preparation/transformation, while the reported test cases took less than five seconds per file. The real-reader file exercises state-root capture, admission invalidation and actual worker-backed revision loading that mocked publication tests cannot establish.

Timing from successful CI run 35607177457 at 7d4cd6e8796bb658a7640fce3cabcc36b4f5c141:

Changed test file CI reported case-time sum Enclosing Vitest shard wall Enclosing job wall
src/skills/runtime/embedded-run-entries.test.ts 0.037 s (15 cases) 168.69 s 525 s
src/skills/runtime/embedded-run-entries.library-read.test.ts 2.135 s (5 cases) 312.58 s 615 s

CI does not report isolated per-file elapsed time. Case-time sums exclude transformation, imports and setup. The unit shard spans 214 files (212 passed, two skipped); the reader shard spans 54 passed files. Job times include setup, multiple shard plans and cleanup; their Node test steps took 467 s and 577 s respectively. These values are separate from the local single-file, single-worker wall measurements.

@clawsweeper

clawsweeper Bot commented Sep 15, 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 size: M maintainer Maintainer-authored PR labels Sep 15, 2026
@steipete
steipete marked this pull request as ready for review September 15, 2026 01:42
@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 Sep 15, 2026
@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 21, 2026, 10:33 AM ET / 14:33 UTC (Revision 11).

ClawSweeper review

What this changes

Prepares saved skill Library entries asynchronously and publishes the combined workspace and Library cache only after preparation succeeds.

Merge readiness

✅ Ready for maintainer review

The PR remains useful: current main and the latest release still contain the synchronous read and premature cache publication. The previous timing request is satisfied, and this review found no blocking defect.

Priority: P2
Reviewed head: 7d4cd6e8796bb658a7640fce3cabcc36b4f5c141

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful race and real-reader coverage, reusable runtime evidence, and the prior timing request resolved.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): Retained compiled Node/Bun proof exercises the production Getter with cold Library reads and observes complete ordered entries without parent SQLite calls. Its original candidate identity is preserved; matching production/test blobs and fresh current-head qualification support reuse without claiming a new compiled run.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): Retained compiled Node/Bun proof exercises the production Getter with cold Library reads and observes complete ordered entries without parent SQLite calls. Its original candidate identity is preserved; matching production/test blobs and fresh current-head qualification support reuse without claiming a new compiled run.
Evidence reviewed 9 items Introduced change and publication boundary: The pinned parent-to-head diff captures pins before any workspace wait, uses the existing asynchronous Library owner, checks caller and database admission after waits, retries changed workspace sources, and retains the first complete cache publication. Workspace-only loading excludes Library pins.
Still necessary on current main: Current main assigns workspace entries to the cache before calling synchronous loadSkillLibrarySelection. A Library failure therefore leaves a partial cache available to later calls.
Latest release comparison: The same synchronous Library call and early workspace-cache assignment are present in v2026.9.5; the requested behavior is not already shipped there.
Findings None None.
Security None None.

How this fits together

Skill preparation combines workspace skills with revisions saved in a session’s Library selections. Embedded agents and CLI runners consume these entries when preparing their skill prompts.

flowchart TD
  A[Session skill selections] --> B[Capture pins and storage context]
  B --> C[Prepare workspace skills]
  C --> D[Read Library metadata in worker]
  D --> E{Caller and sources current?}
  E -->|Sources changed| C
  E -->|Yes| F[Publish complete cached entries]
  F --> G[Agent and CLI skill prompts]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +32, Tests +365, Docs +11. Total +408 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 1 45 13 +32
Tests 3 366 1 +365
Docs 1 11 0 +11
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 422 14 +408

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net +32 lines; tests net +364; test routing +1 Production growth implements complete publication and invalidation checks; most added code exercises races and the real reader boundary.
Changed-test cost Local wall: 140.85 s and 66.20 s; CI case sums: 0.037 s and 2.135 s The previous timing request is satisfied, with preparation overhead distinguished from case execution.

Technical review

Best possible solution:

Use the existing worker-backed Library reader while preserving immutable selections, sandbox isolation, and complete cache publication.

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

Yes, from source: an uncached load performs synchronous Library reads, and a Library failure leaves workspace-only entries cached on current main. This review did not execute that failure path.

Is this the best way to solve the issue?

Yes. The patch uses the existing asynchronous owner and moves publication after complete preparation without changing selection, schema, or configuration contracts.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded skill-preparation reliability and responsiveness fix without evidence of an urgent production outage.
  • 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 (terminal): Retained compiled Node/Bun proof exercises the production Getter with cold Library reads and observes complete ordered entries without parent SQLite calls. Its original candidate identity is preserved; matching production/test blobs and fresh current-head qualification support reuse without claiming a new compiled run.
  • proof: sufficient: Contributor real behavior proof is sufficient. Retained compiled Node/Bun proof exercises the production Getter with cold Library reads and observes complete ordered entries without parent SQLite calls. Its original candidate identity is preserved; matching production/test blobs and fresh current-head qualification support reuse without claiming a new compiled run.

Evidence

What I checked:

  • Introduced change and publication boundary: The pinned parent-to-head diff captures pins before any workspace wait, uses the existing asynchronous Library owner, checks caller and database admission after waits, retries changed workspace sources, and retains the first complete cache publication. Workspace-only loading excludes Library pins. (src/skills/runtime/embedded-run-entries.ts:56, 7d4cd6e8796b)
  • Still necessary on current main: Current main assigns workspace entries to the cache before calling synchronous loadSkillLibrarySelection. A Library failure therefore leaves a partial cache available to later calls. (src/skills/runtime/embedded-run-entries.ts:63, a3f9972a981e)
  • Latest release comparison: The same synchronous Library call and early workspace-cache assignment are present in v2026.9.5; the requested behavior is not already shipped there. (src/skills/runtime/embedded-run-entries.ts:63, ec9c1a13db89)
  • Existing owner and dependency boundary: The asynchronous selection owner already reads descriptions through OpenClaw’s shared state reader and preserves the existing materializer, selection limits, and file guards. This patch consumes that owner without adding SDK exports, storage formats, or a Codex dependency. (src/skills/library/selection.ts:235, 7d4cd6e8796b)
  • Review continuity resolved: The captured PR body now supplies the requested separate single-worker wall measurements: 140.85 seconds for the publication tests and 66.20 seconds for the real-reader tests. It also supplies CI case-time sums, enclosing shard/job durations, and explains transformation overhead. The earlier pin-capture finding is resolved by capturing values outside the retry loop. (src/skills/runtime/embedded-run-entries.ts:56, 7d4cd6e8796b)
  • Retained runtime evidence: The captured body reports compiled Node/Bun Getter proof on 9d8ab6e: four fresh readers calibrated SQLite construction and seven methods, then observed zero parent SQLite calls through imports, loading, and close while preserving entries, ordering, caching, and workspace-only isolation. GitHub commit metadata independently confirms identical production and changed-test blob identities on the reviewed head. This preserves the historical proof without claiming a fresh compiled run. (src/skills/runtime/embedded-run-entries.ts:52, 9d8ab6e19fa7)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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 (10 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-15T05:46:34.812Z sha edc38df :: blocked before merge. :: none
  • reviewed 2026-09-15T10:02:33.454Z sha edc38df :: needs maintainer review before merge. :: none
  • reviewed 2026-09-20T09:16:28.450Z sha 71e6005 :: blocked before merge. :: none
  • reviewed 2026-09-21T07:57:41.110Z sha 71e6005 :: blocked before merge. :: [P2] Capture pin values before entering the preparation retry loop
  • reviewed 2026-09-21T09:22:09.849Z sha 9d8ab6e :: needs changes before merge. :: none
  • reviewed 2026-09-21T09:42:14.053Z sha 9d8ab6e :: needs changes before merge. :: none
  • reviewed 2026-09-21T10:33:55.604Z sha 9d8ab6e :: needs changes before merge. :: none
  • reviewed 2026-09-21T13:54:22.557Z sha 7d4cd6e :: needs changes before merge. :: none

@steipete
steipete marked this pull request as draft September 15, 2026 02:02
@steipete
steipete force-pushed the codex/library-resource-read-stacked branch from ae1c055 to ebba6cd Compare September 15, 2026 05:27
@steipete
steipete force-pushed the codex/embedded-library-1cd-20260914 branch from c92562d to edc38df Compare September 15, 2026 05:38
@steipete
steipete marked this pull request as ready for review September 15, 2026 05:40
@steipete
steipete marked this pull request as draft September 15, 2026 09:43
@steipete
steipete force-pushed the codex/library-resource-read-stacked branch 2 times, most recently from 09d71c6 to d21c12d Compare September 20, 2026 08:53
@steipete
steipete force-pushed the codex/embedded-library-1cd-20260914 branch from edc38df to 71e6005 Compare September 20, 2026 09:09
@steipete
steipete force-pushed the codex/library-resource-read-stacked branch 5 times, most recently from b0682aa to b2ca321 Compare September 21, 2026 07:08
Base automatically changed from codex/library-resource-read-stacked to main September 21, 2026 07:47
@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. 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 Sep 21, 2026
@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. labels Sep 21, 2026
@steipete
steipete force-pushed the codex/embedded-library-1cd-20260914 branch from 71e6005 to 9d8ab6e Compare September 21, 2026 09:13
@clawsweeper clawsweeper Bot added 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. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 21, 2026
@steipete
steipete marked this pull request as ready for review September 21, 2026 09:33
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 21, 2026
Use the shared reader for pinned Library descriptions. Capture pin values and
state admission before workspace preparation, publish complete entries only
while the caller and source version remain current, and preserve the first
completed cache publication.

Prove cold reads, mutation during workspace waits, admission invalidation,
concurrent publication, and embedded/CLI caller behavior. No schema, retention,
durability, permission, configuration, or dependency change is introduced.
@steipete
steipete force-pushed the codex/embedded-library-1cd-20260914 branch from 9d8ab6e to 7d4cd6e Compare September 21, 2026 13:40
@steipete
steipete merged commit 290d5c3 into main Sep 21, 2026
220 checks passed
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@steipete
steipete deleted the codex/embedded-library-1cd-20260914 branch September 21, 2026 15:13
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 22, 2026
…enclaw#148679)

Use the shared reader for pinned Library descriptions. Capture pin values and
state admission before workspace preparation, publish complete entries only
while the caller and source version remain current, and preserve the first
completed cache publication.

Prove cold reads, mutation during workspace waits, admission invalidation,
concurrent publication, and embedded/CLI caller behavior. No schema, retention,
durability, permission, configuration, or dependency change is introduced.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation maintainer Maintainer-authored PR 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. size: M 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