Repository navigation
perf(sqlite): make profile admission authority transferable - #170470
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs real behavior proof before merge. What this changesThis 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.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete 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 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherProfile 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]
Technical reviewBest 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
TestingProof path: in-process harness. SecurityNeeds attention: No concrete authorization bypass was found; the changed bindings remain security-sensitive. EvidenceWhat I checked:
PR surfaceSource +303, Tests +348, Docs +23. Total +674 across 13 files. Added test files: 2. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed October 12, 2026, 9:16 PM ET / October 13, 2026, 01:16 UTC (Revision 2). |
…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.
|
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 |
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.
…#170470) * perf(sqlite): transfer profile authority to admission worker * perf(sqlite): defer service dispatch until authority cutover
…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.
…#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.
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
git diff --checkpassed. Independent reviews are clean through P2 for the complete contract and final RPC removal.c6eaf79bd0dddaa78fb4d5e9942ffdafe0b63f3cin 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; candidatec6eaf79bd0dddaa78fb4d5e9942ffdafe0b63f3c. Candidate patch SHA-2566b4a77d4624f659c52105f3ed2da30682e4356d864c2f30551573685913265fd; 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.
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.
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.