Skip to content

perf(accounts): avoid materializing avatars for owner checks - #147032

Merged
steipete merged 2 commits into
mainfrom
codex/team-model-account-owner-read
Sep 13, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/team-model-account-owner-read

Conversation

@steipete

@steipete steipete commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Related: #146953

What Problem This Solves

Personal model-account ownership checks materialized the entire user-profile row, including avatar bytes, although they only use the canonical ID and merge status. Repeated metadata and account reads paid that allocation cost unnecessarily.

How This Fixes It

Select only id and merged_into through the existing merge-aware profile resolver. All account readers and writers retain their current owner checks, one-hop merge behavior, and refusal of missing or unresolved owners. No cache, schema, permission, or public-contract change is involved.

Evidence

Four real SQLite regressions deny access to the avatar column and exercise direct ownership, completed merges, missing merge targets, and unflattened tombstones. All four fail with the original query and pass after the change. Public link, ownership, and pinned-credential reads remain covered, as do invalid-owner write refusals.

All 91 focused owner/profile tests pass on current main. Type-aware lint, formatting, and independent review through P2 pass. The state/logging type graph and reclamation-memory runtime regression pass after integrating the canonical main fixture repair in #147028. Exact-head CI passed on d4e435739d477552bef921a9c76d86152b657248. This change proves avoided avatar materialization, not elimination of all physical page reads or attribution of all server CPU to this lookup.

@clawsweeper

clawsweeper Bot commented Sep 13, 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 size: S maintainer Maintainer-authored PR labels Sep 13, 2026
@steipete steipete self-assigned this Sep 13, 2026
@steipete
steipete marked this pull request as ready for review September 13, 2026 12:53
@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 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 9:22 AM ET / 13:22 UTC (Revision 2).

ClawSweeper review

What this changes

Personal model-account checks read only profile identity and merge status instead of loading avatar bytes, with regression coverage for valid and unresolved owners.

Merge readiness

✅ Ready for maintainer review

The optimization remains useful on current main, and no actionable patch defect was found. The related merged work does not supersede it; the maintainer-designated PR should remain open for normal landing.

Priority: P2
Reviewed head: d4e435739d477552bef921a9c76d86152b657248

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused optimization with meaningful regression coverage and no identified correctness or security blocker.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-designated PR is exempt from external-contributor proof requirements. Its reported SQLite regressions exercise the changed account owner and avatar exclusion; they do not establish end-to-end latency gains. No material authority change triggers additional proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-designated PR is exempt from external-contributor proof requirements. Its reported SQLite regressions exercise the changed account owner and avatar exclusion; they do not establish end-to-end latency gains. No material authority change triggers additional proof.
Evidence reviewed 7 items Introduced change preserves owner semantics: The complete introduced diff changes only the selected profile columns and adds regression cases. resolveOwner still rejects missing profiles and unresolved tombstones; credential checks, transaction boundaries, and final authorization callbacks remain unchanged.
Existing resolver supplies the same merge behavior: The generic resolver reads the requested profile, follows exactly one merge target, and retains the source tombstone if that target is missing. The former full-row wrapper delegates to this same resolver using selectAll.
Focused regression coverage: Four cases deny SQLite reads of the avatar column while exercising public account-link, ownership, and credential reads for direct owners, completed merges, missing targets, and unflattened chains. Invalid-owner writes must still fail. The author reports before/after failures and 91 passing focused tests; this read-only review did not execute them.
Findings None None.
Security None None.

How this fits together

Personal model accounts store credentials and provider selections under a canonical user profile. Chat metadata and account operations resolve that profile before reading or changing its account records.

flowchart TD
  A[Chat metadata or account operation] --> B[Profile identity lookup]
  B --> C[Read identity and merge status]
  C --> D[Resolve existing merge target]
  D --> E{Valid canonical owner?}
  E -->|Yes| F[Read or update account records]
  E -->|No| G[Empty result or owner error]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +4, Tests +67. Total +71 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 6 2 +4
Tests 1 69 2 +67
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 75 4 +71

Review metrics

None.

Technical review

Best possible solution:

Keep canonical owner resolution centralized and project only the fields account operations consume.

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

Yes, by source inspection: main's account-owner lookup delegates to selectAll, which includes avatar bytes even though only identity and merge status are consumed. Runtime allocation and latency were not measured in this review.

Is this the best way to solve the issue?

Yes. Reusing the existing resolver with a narrower projection removes unnecessary materialization without introducing caches, duplicate resolution policy, or migration work.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded performance improvement to repeated account and chat-metadata reads.
  • 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 maintainer-designated PR is exempt from external-contributor proof requirements. Its reported SQLite regressions exercise the changed account owner and avatar exclusion; they do not establish end-to-end latency gains. No material authority change triggers additional proof.

Evidence

What I checked:

  • Introduced change preserves owner semantics: The complete introduced diff changes only the selected profile columns and adds regression cases. resolveOwner still rejects missing profiles and unresolved tombstones; credential checks, transaction boundaries, and final authorization callbacks remain unchanged. (src/state/user-model-accounts.ts:83, d4e435739d47)
  • Existing resolver supplies the same merge behavior: The generic resolver reads the requested profile, follows exactly one merge target, and retains the source tombstone if that target is missing. The former full-row wrapper delegates to this same resolver using selectAll. (src/state/user-profiles-internal.ts:41, d4e435739d47)
  • Focused regression coverage: Four cases deny SQLite reads of the avatar column while exercising public account-link, ownership, and credential reads for direct owners, completed merges, missing targets, and unflattened chains. Invalid-owner writes must still fail. The author reports before/after failures and 91 passing focused tests; this read-only review did not execute them. (src/state/user-model-accounts.test.ts:85, d4e435739d47)
  • Current-main and release necessity: Pinned main still calls the full-row resolver. Reading the same file from v2026.9.4 through GitHub also showed that call, so neither inspected revision contains this optimization. (src/state/user-model-accounts.ts:87, 0a7b7fecfd7f)
  • Re-review continuity and related work: Comparison with the earlier reviewed head produced no changes in either reviewed file. The previous completed review retained no findings. fix: avoid repeated background reads while loading chat #146953 addresses other background reads; fix(sessions): align the reclamation-memory test with the archive session owner #147028 repairs a separate session test and entered through main integration. (d4e435739d47)
  • Feature-history routing: Main-path history identifies the prior prepared-profile optimization and connected-account implementation. GitHub commit metadata and patches confirm steipete's resolver work at a22f9d8 and scoootscooob's account-file contribution at e4e2305. Local blame/follow traversal encountered unavailable historical objects, so no broader introduction claim is made. (src/state/user-profiles-internal.ts:41, a22f9d8ef77e)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • scoootscooob: 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 (1 earlier review cycle)
  • reviewed 2026-09-13T12:59:09.678Z sha afc978b :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 66053b4 into main Sep 13, 2026
193 checks passed
@steipete
steipete deleted the codex/team-model-account-owner-read branch September 13, 2026 13:33
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 13, 2026
* commit '0ac8a700e43efceef73d92fe8e50b185819e38ad': (27 commits)
  test(acpx): prove targeted turn cancellation (#137049)
  fix(ci): honor realtime meeting live-test opt-in (#147044)
  improve: reduce heartbeat enrollment work for large fleets (#147055)
  fix(gateway): install despite stale Linux session bus addresses (#146569)
  chore(i18n): refresh native locales (#147025)
  fix: avoid Gateway reinstalls when macOS service inspection is inconclusive (#146880)
  fix(pairing): QR setup rejects trusted-proxy gateways without a shared secret (#147036)
  fix(update): bound activation and accept slow Windows identity reads (#147019)
  perf(accounts): avoid materializing avatars for owner checks (#147032)
  improve(status): report external and ArrayBuffer memory (#141902)
  fix(update): preserve linked plugins during post-core sync (#147009)
  fix(channels): keep replies working after hot config reloads (#147001)
  refactor(gateway): defer worker transcript runtime loading (#143495)
  improve: reduce GitHub OAuth maintenance work for large agent rosters (#147021)
  fix(test): avoid settings lock writer startup timeouts (#147029)
  fix(update): correct backup guidance and cover incident regressions (#147023)
  refactor(gateway): share connection lifecycle across transports (#145950)
  refactor(telegram): share HTML text escaping (#146936)
  perf(build): reduce disk use in UI performance checks (#146687)
  refactor(memory-wiki): share freshness result construction (#146935)
  ...

# Conflicts:
#	src/config/sessions/session-accessor.sqlite-reclamation-memory.test.ts
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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: S 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