Skip to content

improve: reduce data fetched for profile metadata operations - #148953

Merged
steipete merged 1 commit into
mainfrom
codex/sqlite-profile-metadata-projection-0915
Sep 15, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/sqlite-profile-metadata-projection-0915

Conversation

@steipete

@steipete steipete commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Related: #146197

What Problem This Solves

Skill-library authorization and profile preference operations fetch stored avatars when they only need profile metadata.

User Impact

These operations avoid copying avatar BLOBs into JavaScript. Profile resolution, missing-profile errors, and avatar access retain their behavior. No operator action or data migration is required.

Why This Change Was Made

Metadata reads omit BLOB avatars while retaining non-BLOB values and numeric columns for existing native validation. Required-profile callers use the same resolution owner, including merged aliases and missing merge targets. Cold and legacy handles retain their fallback; avatar reads and adoption keep their full-row reads.

The role-schema cache now follows transaction rollback, so a rolled-back legacy migration cannot make subsequent metadata reads select a nonexistent column.

Evidence

Native SQLite measurements through actual library operations and the preference handler on Node 24.19.0:

Case Avatar BLOB bytes before → after Queries and rows, unchanged
Library, canonical actor 393,216 → 0 9
Library, merged actor 786,432 → 0 12
Preferences, main-thread handle 262,144 → 0 4

TEXT bytes were also unchanged. The preference measurement does not include worker-thread SQL. No latency, heap, or disk-I/O improvement is claimed.

  • 141 affected tests passed, covering library permissions, preference notifications, authoring, profile resolution, aliases, and avatar lifetime. After moving the legacy-schema tests into a focused sibling file, all 56 tests in both profile files passed again.
  • Both rollback regressions fail on the original cache behavior and pass with the fix. Baseline library/preference cases fail only their intended BLOB budgets; compatibility controls pass.
  • Final independent review found no actionable issues. Selected formatting, typechecking, lint, dead-export, storage, and authorization checks passed. Exact-head CI passed on a5ffb586bed46443d91718e694748192d6df4256.

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

@steipete
steipete marked this pull request as ready for review September 15, 2026 09:11
@steipete
steipete requested a review from a team as a code owner September 15, 2026 09:11
@steipete steipete self-assigned this Sep 15, 2026
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: L maintainer Maintainer-authored PR labels Sep 15, 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 Sep 15, 2026
@clawsweeper

clawsweeper Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 15, 2026, 5:19 AM ET / 09:19 UTC.

ClawSweeper review

What this changes

The PR avoids loading avatar bytes during profile metadata operations and makes schema-readiness caches follow transaction rollback.

Merge readiness

✅ Ready for maintainer review

This remains a useful, bounded optimization that current main and the latest release do not contain. No actionable correctness defect was found in the introduced changes.

Priority: P2
Reviewed head: a5ffb586bed46443d91718e694748192d6df4256

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused optimization with useful measurements and compatibility coverage; source review found no blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository state identifies maintainer-authored work, so the external-contributor proof gate does not apply. Reported native SQLite measurements exercise library operations and preference recipient selection; worker-thread SQL and latency are expressly outside those measurements.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository state identifies maintainer-authored work, so the external-contributor proof gate does not apply. Reported native SQLite measurements exercise library operations and preference recipient selection; worker-thread SQL and latency are expressly outside those measurements.
Evidence reviewed 7 items Introduced change boundary: Reviewed the merge-base-to-head changes at a5ffb58. Host-verified test-merge evidence identifies the same introduced paths; unrelated base-branch changes were excluded.
Projection preserves resolution and validation: The metadata selector reuses the existing one-hop resolver, retains numeric and non-BLOB values for native conversion, and falls back to full rows on cold or legacy handles. Avatar retrieval and adoption retain their full-row reads.
Rollback follows the existing transaction owner: Schema-readiness entries use stageSqliteTransactionState. The shared-state transaction wrapper already restores staged state on nested and outer rollback; the added regression cases exercise both scopes through profile operations. No DDL or persisted-format change is introduced.
Findings None None.
Security None None.

How this fits together

OpenClaw resolves stored user profiles for skill-library permissions, personal GitHub connections, and preference updates. These operations need identity and role metadata; separate avatar operations need the image bytes.

flowchart TD
  A[Library and preference requests] --> B[Profile lookup]
  B --> C{Role schema known?}
  C -->|Yes| D[Metadata without avatar bytes]
  C -->|No| E[Existing full-row fallback]
  D --> F[Resolve canonical profile]
  E --> F
  F --> G[Existing permissions and operations]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +73, Tests +220. Total +293 across 15 files.

View PR surface stats
Area Files Added Removed Net
Source 9 110 37 +73
Tests 6 312 92 +220
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 15 422 129 +293

Review metrics

Metric Value Why it matters
Reported avatar transfer reduction 100% fewer BLOB bytes in 3 measured cases The measurements support reduced JavaScript payload materialization without claiming latency, heap, or disk-I/O improvements.
Production versus test growth Production +73 net lines; tests and test support +220 Production growth implements validation-preserving projection and rollback handling; test growth covers those compatibility boundaries.

Technical review

Best possible solution:

Keep metadata projection with the existing profile resolver, preserving avatar access, legacy reads, native validation, and transaction-owned cache invalidation.

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

Not applicable to the primary performance improvement; current source confirms unnecessary full-row reads, and the PR reports concrete before/after byte measurements.

Is this the best way to solve the issue?

Yes. The change narrows reads inside the existing resolution owner while preserving its fallback, error, permission, and avatar contracts.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This is a bounded optimization of existing profile operations with a related schema-cache correctness repair.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied repository state identifies maintainer-authored work, so the external-contributor proof gate does not apply. Reported native SQLite measurements exercise library operations and preference recipient selection; worker-thread SQL and latency are expressly outside those measurements.

Label justifications:

  • P2: This is a bounded optimization of existing profile operations with a related schema-cache correctness repair.
  • 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 supplied repository state identifies maintainer-authored work, so the external-contributor proof gate does not apply. Reported native SQLite measurements exercise library operations and preference recipient selection; worker-thread SQL and latency are expressly outside those measurements.

Evidence

What I checked:

  • Introduced change boundary: Reviewed the merge-base-to-head changes at a5ffb58. Host-verified test-merge evidence identifies the same introduced paths; unrelated base-branch changes were excluded. (a5ffb586bed4)
  • Projection preserves resolution and validation: The metadata selector reuses the existing one-hop resolver, retains numeric and non-BLOB values for native conversion, and falls back to full rows on cold or legacy handles. Avatar retrieval and adoption retain their full-row reads. (src/state/user-profiles-internal.ts:71, a5ffb586bed4)
  • Rollback follows the existing transaction owner: Schema-readiness entries use stageSqliteTransactionState. The shared-state transaction wrapper already restores staged state on nested and outer rollback; the added regression cases exercise both scopes through profile operations. No DDL or persisted-format change is introduced. (src/state/user-profiles-schema.ts:92, a5ffb586bed4)
  • Still needed on main and release: Inspected the profile resolver at fetched main a10df27 and latest-release commit 3a9d69d for v2026.9.4. Both retain selectAll() in the full-profile lookup and lack this metadata selector. (src/state/user-profiles-internal.ts:57, a10df27f8d55)
  • Measured scope and regression coverage: The captured PR body reports Node 24.19.0 measurements reducing avatar transfers from 393,216, 786,432, and 262,144 bytes to zero for canonical-library, merged-library, and main-thread preference operations respectively. Query, row, and TEXT counts stayed unchanged. Reviewed tests cover role restrictions, aliases, cold/legacy handles, native conversion failures, notifications, and avatar preservation. Tests were not executed during this read-only review; git diff --check passed. (src/skills/library/service.test.ts:478, a5ffb586bed4)
  • Campaign context: The linked open campaign Reduce SQLite fetch and payload materialization overhead #146197 explicitly includes profile metadata projection among its remaining opportunities. This PR addresses that subset rather than replacing the broader campaign.

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.

@steipete
steipete merged commit 237563a into main Sep 15, 2026
267 checks passed
@steipete
steipete deleted the codex/sqlite-profile-metadata-projection-0915 branch September 15, 2026 10:01
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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