Skip to content

perf(sqlite): make profile admission authority transferable - #170470

Merged
steipete merged 2 commits into
mainfrom
steipete/perf-profile-admission-authority-20261012
Oct 13, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/perf-profile-admission-authority-20261012

Conversation

@steipete

@steipete steipete commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Problem and scope

Writer admission waits for Gateway scheduling because live authority is expressed as host callbacks. This is the first executable prerequisite in the writer admission program: transfer profile authority without weakening revocation.

There is no intended user-visible behavior change, schema/configuration change, or update migration. This PR does not claim to move native write admission or chat ACK delivery off the main thread. Mixed authority, final host COMMIT, FIFO ordering and receipt settlement keep their existing owners.

Change

Canonical shared generation/revision/status cells replace profile object-revision tokens and the separate uncertainty set. Native transactions fence transferred readers immediately before physical COMMIT. Known rollback preserves prior bound revisions; unknown outcomes remain fenced. Exact-bound readers remain invalid after committed mutation; current-settled readers can consume later known commits. Descriptors retain exact buffers, so late delivery cannot revive a retired generation.

First creation publishes path-to-file invalidation before identity mutation, including worker-only creation and alias reconciliation. Worker-only close revokes shared lifetime before asynchronous drainage. The read-only admission service factory supports typed bound/current-settled checks and explicit close using the existing worker-task lifecycle. Production assertions consume the same canonical cells; native consumers will be connected after their other authorities transfer.

A measured intermediate implementation added two redundant host-to-service RPCs to profile preparation. It regressed warm role and selection preparation by 17% and 16%, respectively, so those RPCs and their unused singleton wrapper were removed before qualification.

Production LOC: +303 (468 additions, 165 deletions; excludes tests/docs). Growth implements the requested shared publication contract, lifecycle fencing and typed worker transport, which have no existing equivalent. The superseded profile representation is removed; there is one profile authority owner and no cached allow answer.

Validation

  • Focused local tests passed: initial profile/service/channel/transaction files, 56 tests in 125.57 s including cold worker compilation; repair checks, 17 in 96.16 s, 35 in 62.87 s, and 28 in 86.79 s; final detour removal, channel/service checks, 12 in 47.64 s.
  • Adversarial proof covers pre-COMMIT revocation, known rollback, unknown outcome before connection disposal, unrelated-profile bindings, delayed service delivery, first creation, permanent retirement, worker-only close and service crash/restart. The first-creation regression fails on the pre-fix candidate and passes with the repair.
  • Changed-file formatting, focused repository lint, Markdown lint and git diff --check passed. Independent reviews are clean through P2 for the complete contract and final RPC removal.
  • Exact-head full PR CI passed on c6eaf79bd0dddaa78fb4d5e9942ffdafe0b63f3c in 698 s, including typecheck, source/architecture guards, changed suites and e2e. Aggregate CI and security review passed. No Testbox/Crabbox lease used; full gates ran in PR CI under the light-local rule.

Measurements

Team sandbox only, synthetic data, CPUs 64–127, 64 GiB cap, low CPU/I/O priority, owned HOME/state/tmp and loopback ports above 40000. Baseline 78c03ce660508ce7afeb5a2675bf22dec1dd9208; candidate c6eaf79bd0dddaa78fb4d5e9942ffdafe0b63f3c. Candidate patch SHA-256 6b4a77d4624f659c52105f3ed2da30682e4356d864c2f30551573685913265fd; instrumentation and fixture equivalence verified.

Final profile preparation completed four ABBA blocks, 6,432 successful/current preparations and zero production service calls. Warm pooled role p50 0.496→0.503 ms; selection 0.605→0.609 ms. Paired ratios: role 1.051 (95% interval 0.812–1.361), selection 1.062 (0.847–1.333); cold role 0.980 (0.861–1.115), cold selection 0.972 (0.857–1.103). Neutral within substantial host variation; these intervals do not establish tight equivalence.

The lane-830 writer workload completed four ABBA blocks with fresh processes/state: 20 sessions × five measured turns, excluded warmup, history reads, metadata updates, four subscribers, visible observer, tool events and control-plane probes. All 1,600 measured turns and probes passed; each variant exercised 800 profile captures and zero service calls.

Writer metric Baseline Candidate Paired B/A, 95% interval
FIFO queue p50 110.58 ms 112.31 ms 1.014 [0.895, 1.149]
FIFO queue p95 220.93 ms 227.57 ms 1.038 [0.964, 1.118]
FIFO hold mean 7.176 ms 7.293 ms 1.016 [0.948, 1.088]
FIFO occupancy 95.113% 95.106% 1.000 [0.994, 1.006]
Main CPU/turn 266.88 ms 269.79 ms 1.011 [0.933, 1.095]

The writer and profile results are neutral within observed variation. No latency improvement is claimed from this prerequisite.

The original lane-860 ACK reproduction used two persistent warm Gateways, 5,000 synthetic sessions each, 20 clients, one warmup each, and four ABBA blocks (640 successful measured sends/final replies). This preserves the original persistent-process protocol; unlike the writer/profile campaigns, it does not create fresh process/state for every leg. Pooled ACK p50 was 897.37→906.38 ms and p99 1,585.81→1,510.98 ms. Within that process pair, ACK mean was 839.87→893.18 ms (paired 1.065 [1.013, 1.118]) and FIFO queue p50 95.69→105.65 ms (1.110 [1.074, 1.146]). Those positive signals were investigated, not discarded.

  • Both ACK variants recorded zero profile captures/service calls. The common pre-COMMIT scan still executes: a separate diagnostic observed 1,463 calls, 4,437 staged states and 1.869 ms of scan/counter time across 40 successful sends. The timer excludes the function prologue; this is not an inclusive cost bound. No main-thread hook calls occurred.
  • The process pair had different ages, heaps/GC phases and capture-window work counts. Four ABBA blocks with the identical candidate in both slots also produced a positive ACK mean ratio of 1.048 [0.979, 1.122] and p50 ratio of 1.098 [0.839, 1.436], with all 640 sends successful.
  • A final four-block swapped-placement A/B campaign put the candidate in the first slot and baseline in the second. All 640 sends succeeded. Candidate versus baseline: ACK mean 921.54 versus 933.26 ms; queue p50 105.70 versus 106.38 ms; main CPU/send 233.20 versus 242.25 ms. Candidate/baseline paired ratios were mean 0.989 [0.873, 1.120], queue p50 0.988 [0.794, 1.230], and CPU 0.962 [0.843, 1.097]. The original queue increase did not follow the candidate.

These controls identify substantial persistent-process variation rather than a consistent source regression. Descriptive crossover source points from the two A/B process pairs are ACK mean 1.026, queue p50 1.047 and CPU 1.023; two process pairs do not establish a tight source-effect bound. Repeated blocks share their process pair, so the intervals above describe within-pair variation, not independent-process confidence. The requested prerequisite qualifies on the neutral fresh-state writer/profile results and lack of a reproducible regression in the ACK controls; no speedup or tight non-inferiority claim is made. All original, control, interrupted and failed-harness evidence was retained during analysis.

The standalone service diagnostic completed 8,000 checks. Warm round-trip p50 was 0.0288–0.0345 ms; worker CPU 115.1 ms total; V8 allocation approximately 9.4 KB/check including structured clone, transport and profiling. It is a diagnostic of the unchanged service core, not a production latency improvement. Future native transport should avoid unnecessary per-check task-context/serialization cost.

Next owner

Transfer broker request custody: exact slot/job generation, dispatch/cancellation state and revocation before replacement/failure. Preserve the current distinction between aborting queued work and retaining dispatched writes until native outcome/receipt settlement. Reuse physical generation retention from the retention repair. Native-to-service waits must refuse on timeout independently of Gateway scheduling, without replaying unknown writes. Logical/native execution, maintenance, request/run/operator, and config/session/sharing authorities follow in separate owner PRs; final host COMMIT remains required until the dependency graph is complete.

@clawsweeper

clawsweeper Bot commented Oct 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 docs Improvements or additions to documentation size: XL labels Oct 13, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 13, 2026
@clawsweeper

clawsweeper Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR replaces host-local profile revision tokens with shared authority cells and adds a read-only worker service for a later admission cutover.

Example: Alice's prepared administrator authority is retained while her profile changes to member.

  • Before: Host-local revision tokens invalidate Alice's prepared authority after the committed change.
  • After: Shared revision cells invalidate that authority for host readers and transferable worker descriptors.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The accepted implementation has no concrete source finding, but required final-effect authority evidence remains incomplete.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Gateway scheduling can delay admission of database-backed requests.
Reason: Maintainer direction and the merged design authorize this prerequisite; production service dispatch is deliberately deferred until the remaining authority owners can transfer.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep this PR open: it implements the accepted profile-authority prerequisite, and source review found no discrete introduced bug.

Priority: P2
Reviewed head: c6eaf79bd0dddaa78fb4d5e9942ffdafe0b63f3c

Before merge

  • Add real behavior proof - Authority-chain proof required: demonstrate a permitted administrative mutation through the changed profile preparation owner, then retain its prepared authority across demotion or identity reassignment and show rejection before the privileged database effect. Added publisher and real-worker tests establish status fencing but stop before that effect; profile-preparation measurements do not fill this gap. The prior measurement request is partly addressed, but writer and 20-sender ACK results remain explicitly pending. Supply redacted logs or terminal output showing these outcomes, removing credentials, IPs, phone numbers, and non-public endpoints. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve security review attention item - No concrete authorization bypass was found; the changed bindings remain security-sensitive.

Findings

None.

Tests

  • Missing end-to-end proof: Missing coverage is an allowed/forbidden administrative final-effect scenario through the changed bindings and the remaining design-required writer/ACK benchmark results.
Agent review details

How this fits together

Profile mutation owners publish authority state consumed by Gateway preparation and administrative write guards; production dispatch and final COMMIT authorization remain host-owned.

flowchart TD
A[Profile mutation owner] --> B[Shared authority cells]
B --> C[Host profile preparation]
C --> D[Live administrative guard]
D --> E[SQLite transaction and COMMIT]
B --> F[Read only service factory]
F --> G[Worker contract tests]
Loading

Technical review

Best possible solution:

Complete the staged profile prerequisite while preserving live authorization, rollback semantics, and accepted-write settlement.

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

Current-main source confirms host-local profile authority and host-dependent admission; this read-only review did not reproduce the reported scheduling latency.

Is this the best way to solve the issue?

The implementation follows the accepted first slice, removes the superseded representation, and avoids the measured RPC detour while retaining existing effect guards.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Profile authority representation changes intended behavior with a stated reason (c69b8b9: Prepared authority must detect role, identity, and channel changes while accepted writes retain settlement ownership.)
  • Durable recovery revocation keeps the original intent (83d24ab: Original authorization references must not revive after revocation and restoration; mutation retires recovery custody in its transaction.)
  • Account-link authority keeps the original intent (a6b9da2: Worker-backed account operations retain current credential and profile authority while preserving existing public contracts.)
  • Committed publication and failed rollback keeps the original intent (da67a08: Committed writes install facts before observers, preserve their durable outcome, and fence failed installation.)
  • Physical identity and lifecycle changes intended behavior with a stated reason (7fcf912: The state lifecycle owns physical identity, read admission, and drainage; first creation may preserve admission while retirement invalidates retained readers.)

Testing

Proof path: in-process harness.

Security

Needs attention: No concrete authorization bypass was found; the changed bindings remain security-sensitive.

Evidence

What I checked:

PR surface

Source +303, Tests +348, Docs +23. Total +674 across 13 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 9 468 165 +303
Tests 3 348 0 +348
Docs 1 25 2 +23
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 841 167 +674

Review metrics

Metric Value Why it matters
Production versus test growth Production +468/-165; tests +348/-0 Growth implements the accepted shared-publication prerequisite and worker transport; tests cover native settlement and cross-worker lifetime contracts.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded performance prerequisite with no claimed immediate user-visible speedup or urgent regression.
  • merge-risk: 🚨 security-boundary: Shared cells replace bindings consumed by administrative authorization, so revocation must remain effective before privileged writes.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Show an allowed administrative write and rejection after demotion or reassignment before its privileged effect.
  • Publish the remaining paired writer and ACK measurements required by the accepted design, retaining failures and service invocation coverage.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-13T01:03:53.294Z sha 519bc1e :: needs real behavior proof before merge. :: none

Reviewed October 12, 2026, 9:16 PM ET / October 13, 2026, 01:16 UTC (Revision 2).

@steipete steipete changed the title perf(sqlite): transfer profile authority to admission worker perf(sqlite): make profile admission authority transferable Oct 13, 2026
@steipete
steipete merged commit 3b75ce7 into main Oct 13, 2026
146 of 150 checks passed
@steipete
steipete deleted the steipete/perf-profile-admission-authority-20261012 branch October 13, 2026 01:44
steipete added a commit that referenced this pull request Oct 13, 2026
…uthority (#170548)

Since 3b75ce7 (#170470) made profile admission authority transferable, any DDL on the state DB invalidates retained profile authority. Cron's run-receipt and runtime-authority stores re-executed their additive CREATE IF NOT EXISTS DDL on every use, so a manual cron run lost tool authority after the initiating invocation closed ('operator source identity changed'). Both stores now use the existing createSqliteSchemaEnsurer, which only executes DDL when the table/indexes are missing. Restores src/cron/isolated-agent/run.manual-tool-authority.test.ts on main.
@steipete

Copy link
Copy Markdown
Contributor Author

Heads-up for anyone building on this: after this change, any DDL on the state DB revokes retained profile authority. The cron run-receipt and runtime-authority stores re-executed their additive CREATE … IF NOT EXISTS DDL on every use, so manual cron runs lost tool authority after the initiating invocation closed (src/cron/isolated-agent/run.manual-tool-authority.test.ts went 4/4 red on main). Fixed in #170548 (d6bae86) by switching both stores to createSqliteSchemaEnsurer. Other feature-local stores that exec DDL unconditionally on hot paths would hit the same thing.

steipete added a commit that referenced this pull request Oct 13, 2026
The shared additive-schema funnel re-executed CREATE IF NOT EXISTS DDL on every call. It now uses one cached createSqliteSchemaEnsurer per table, checked against admitted schema facts, so DDL only runs when a table or index is missing; four now-redundant tableExists early returns are removed. Hardening sibling of #170548; the profile-authority coupling itself was fixed in c445da4. Net production LOC 0. Refs #170548 #170470.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…#170470)

* perf(sqlite): transfer profile authority to admission worker

* perf(sqlite): defer service dispatch until authority cutover
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…uthority (openclaw#170548)

Since 3310c12 (openclaw#170470) made profile admission authority transferable, any DDL on the state DB invalidates retained profile authority. Cron's run-receipt and runtime-authority stores re-executed their additive CREATE IF NOT EXISTS DDL on every use, so a manual cron run lost tool authority after the initiating invocation closed ('operator source identity changed'). Both stores now use the existing createSqliteSchemaEnsurer, which only executes DDL when the table/indexes are missing. Restores src/cron/isolated-agent/run.manual-tool-authority.test.ts on main.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…#170598)

The shared additive-schema funnel re-executed CREATE IF NOT EXISTS DDL on every call. It now uses one cached createSqliteSchemaEnsurer per table, checked against admitted schema facts, so DDL only runs when a table or index is missing; four now-redundant tableExists early returns are removed. Hardening sibling of openclaw#170548; the profile-authority coupling itself was fixed in 3c2e0ec. Net production LOC 0. Refs openclaw#170548 openclaw#170470.
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 merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant