Repository navigation
Conversation
Retain the MessagePort-detached snapshot for private receipt checks while preserving the mutable authorization callback copy. Remove two redundant full-snapshot clone passes per admission without changing grant ordering, live authority checks, or settlement.
|
🦞👀 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 maintainer review before merge. What this changesThis PR reuses MessagePort-detached admission snapshots for private receipt comparisons while retaining a separate copy for mutable authorization callbacks. Example: An authorization callback changes sessionId to "policy-mutated" during a patch setting updatedAt to 123.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR: it removes redundant snapshot copies from a shared session-write path, preserves callback isolation and live grant checks, and has no identified correctness defect. Current main still performs the extra copies. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherSession actors coordinate session mutations through the existing SQLite worker and physical writer queue; worker admission snapshots enter the host authorization handler, and verified committed receipts publish state to the host replica. flowchart LR
A[Session command] --> B[Existing SQLite writer queue]
B --> C[Actor transaction kernel]
C --> D[Private MessagePort]
D --> E[Host admission handler]
E --> F[Detached policy callback copy]
E --> G[Private receipt comparison]
G --> H[Committed host replica]
Technical reviewBest possible solution: Land the shared-owner optimization once the normal required checks complete. Do we have a high-confidence way to reproduce the issue? Current-main source shows three complete snapshot clones per actor admission; the supplied paired measurements support their host-cost impact, but no target code was executed during this review. Is this the best way to solve the issue? Reusing the already detached snapshot is a narrow solution at the existing owner, and retaining the mutable callback copy preserves the original isolation contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8234359c0b16. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource 0, Tests +32, Docs +4. Total +36 across 3 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
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 Reviewed October 11, 2026, 9:40 AM ET / 13:40 UTC. |
…69125) Retain the MessagePort-detached snapshot for private receipt checks while preserving the mutable authorization callback copy. Remove two redundant full-snapshot clone passes per admission without changing grant ordering, live authority checks, or settlement.
First-parent upstream 19fe879..0bc7491 (100 commits, including openclaw#169090 entry-writer postimages, openclaw#169201 transcript projection facts, openclaw#169113/openclaw#169107/openclaw#169125 session-actor admission, openclaw#169110 bounded worker heaps, openclaw#169130 inter-session provenance, openclaw#168931 Solid session UI). Conflicts: - session-accessor.sqlite-entry-mutation.ts: openclaw#169090 moved postimage publication into writeSessionEntry and replaced the revision-equality no-op check with postimages.changed. Took upstream's form; kept our recipient-authority advance on visibility narrowing (same transaction, after the write, before the no-op return). - session-accessor.sqlite-entry-store.ts: import union (upstream dropped withProjectedParticipants/SessionEntryWindowFacts imports; ours adds the recipient-authority advance). Overlay vs upstream is now 2 lines. - openclaw-tools.types.ts: import union (our RequestCompactionToolOpts, upstream's SessionsYieldRuntimeClaim). - plugin-sdk-surface-report.mts: upstream raised the budgets to 3672/2133; ours stays +11/+4 on top (3683/2137). - worker-access-inventory.md: regenerated on the merged tree. Auto-merged files that carry continuation overlay (21) keep the overlay byte-for-byte (interdiff of the +/- lines vs upstream before and after). Refs #1475 Co-Authored-By: Claude Opus 5.5 <[email protected]>
What Problem This Solves
Tool-heavy sessions repeatedly copy complete actor snapshots on the Gateway main thread while SQLite workers wait for admission. Snapshot cost grows with transcript anchors, idempotency keys, and model-context membership.
User Impact
Lower host CPU and allocation during session writes, with unchanged authorization, FIFO ordering, refusal/timeout behavior, and committed-state publication. No schema, configuration, stored-data, or update change.
Why This Change Was Made
Actor admission was cloning a snapshot already detached by its private MessagePort three times. Retain that received snapshot for private receipt comparisons and keep one detached copy for the mutable policy callback. No new cache, lifecycle, or fast path is introduced.
The callback copy remains because
SessionActorAuthority.authorizeaccepts mutable state; callback mutations must not rewrite native commit evidence. Production LOC is unchanged (three lines replaced), with two full-snapshot clone operations removed rather than another implementation added.Evidence
cbx_71b4d7afedaa,node scripts/run-vitest.mjs src/config/sessions/session-actor*.test.ts src/infra/sqlite-worker-operation-admission.test.ts src/infra/sqlite-worker-operation-admission.timeout.test.ts --maxWorkers=1: 92 tests passed across seven files, 48.08 s wrapper wall time (50.19 s remote command). The new isolation case took 148 ms.tbx_01m4ncrmjcf4n115n4cckv653vnever acquired a runner; it timed out after 15 minutes and is stopped. All executed validation uses the AWS fallback.node scripts/check-changed.mjs: all preceding checks passed, including core types and all 28 test type graphs; the repository-wide dead-export scan reported unused exports in untouched chat UI and subagent-store files. The identical findings reproduced on unchangedd1618ccd0b276f985711ff297b1b87a77bdad35din the same hydrated checkout (exit 1); the candidate was restored byte-for-byte afterward. All remaining checks passed separately through the source-owned check plan. No failing scan was skipped or relabeled green.node scripts/run-vitest.mjs src/config/sessions/session-actor.test.ts --maxWorkers=1: 12 passed, 29.55 s wall time including worker preparation; the new test took 158 ms (about 0.16 CI seconds).Paired Node 24.19.0 Linux measurements on AWS
c7a.8xlarge, comparing baselined1618ccd0b276f985711ff297b1b87a77bdad35dagainst this patch in the same process. Each cell is the median of six samples of 1,024 admissions, with one warmup sample discarded and variant order alternated. Main-thread CPU is measured around the real MessagePort receive/service handler and actor admission callback; sender serialization and SQL are outside the interval.These are focused host-cost measurements and a synthetic session workload, not a live Gateway CPU or traffic claim. No live deployment or database was accessed.
Remote commands all used AWS lease
cbx_71b4d7afedaaafter the Testbox timeout: focused tests (run_948a25a99cdd724dfe6ddd6bbc72a0f0, passed); count probe plusnode scripts/check-changed.mjs(run_0eb8ae32901bd94e030fb516ff89c56b, count passed, inherited export failure); corrected CPU probe, single-file test, and remaining planned checks (run_d753a34bfa001949492bd26512978ed7, passed); unchanged-basenode --import ./scripts/tsx.mjs scripts/check-deadcode-exports.mts(run_49bbc444c8a3fbf5171491d455dd5496, reproduced the same failure in 93.28 s). An initial separate-worktree baseline attempt could not resolve its UI dependency and was discarded as invalid evidence. Both leases are stopped.