Skip to content

perf(sessions): reuse committed identity after entry patches - #136361

Merged
steipete merged 2 commits into
openclaw:mainfrom
quangtran88:perf/session-entry-patch-reparse
Sep 5, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
quangtran88:perf/session-entry-patch-reparse

Conversation

@quangtran88

@quangtran88 quangtran88 commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Related: #136338, #119720, #136283

Session entry patches decoded the entire saved entry again after the canonical writer had already returned the committed value. Identity notifications only consume the session ID and canonical key, so they can reuse that result. This removes one full saved-prompt decode and participant projection from each successful patch.

The final change keeps preparation, commit revalidation, the writer's fresh provenance check, and callback ordering. It replaces the proposed raw-row snapshot cache with a direct reuse of the committed identity. Schema, persisted representations, writer ownership, and public behavior stay unchanged. Production delta: +2/-1; tests: +62/-1.

Validation:

  • Two regression cases exercise the real SQLite entry and lifecycle-target patch APIs with a 16 KiB saved prompt. On main 74b764e81d4b5ba62ffb7441ebe0d4ba85909388, ten patches produce 40 full-payload JSON decodes and fail the 30-decode budget. The repair passes that budget, retains the complete prompt, and emits exactly five identity changes across the ten writes.
  • All 65 session-row and accessor conformance tests pass on that trusted main snapshot with the final patch, isolated temporary HOME/state, Node 24.20.0, and repository-pinned dependencies. The published integration preserves the contributor's ancestry and has the byte-identical reviewed patch against that pinned main.
  • Independent source review and isolated automated review found no actionable correctness issues. Exact-head CI passed for 7bacafe8faac1d693ed1d014ebc45523a4267b55.

Standalone built-runtime proof now also passes. A normal sourcePerformance build used the complete source tree 6ec1f7bc11405b764e7bd438f56fca27ce45878c, identical to this PR head. A separate Node 24.20 process loaded normal temporary configuration and the built public session-store SDK, with no Vitest or mocked production owners. Ten SDK updates produced exactly 30 full saved-prompt decodes and five correct identity replacements; all 16,407 prompt bytes survived. SQLite schema hashes stayed equal at user_version 19, and a reopened SDK read returned the final identity and prompt. The instrumented update sequence took 28.2 ms; this is not a whole-Gateway throughput measurement.

A separate real pnpm --silent openclaw sessions --agent main --json --limit all invocation read the same store and returned count 1, key agent:main:runtime-identity-proof, and final sessionId runtime-generation-4. The data-model classifier is not applicable: row bindings, serialization, schemas, and stored representations are unchanged; only the in-memory identity map after the write is reused.

This establishes reduced per-patch decoding work; it does not establish a total Gateway throughput improvement or resolve the broader issues above.

Thanks @quangtran88 for identifying the repeated decode and contributing the original PR.

…ntry patch

patchSqliteSessionEntrySnapshot read and JSON-decoded the session row at
preparation, again inside the write transaction to revalidate (then
JSON.stringify-compared both copies), a third time inside writeSessionEntry for
the canonical previous entry, and a fourth time after the write for the identity
diff, running the participants projection query on every decode. A streamed
reply turn issues about eleven such patches, so with a prod-shaped ~17 KB
entry_json the session store took 29% of a saturated gateway main thread on
2026.8.2 against 3.6% for the JSON store on 2026.7.1-2.

Snapshot rows now carry the raw persisted row they were decoded from. At commit,
readUnchangedLifecycleTargetSnapshot re-reads the raw rows for exactly the keys
the snapshot reader consults and reuses the prepared snapshot when every column
is identical; any difference falls back to the original full re-decode and deep
compare, so conflict detection is unchanged. writeSessionEntry accepts the
canonical previous entry the commit already holds, and the post-commit identity
map is built from the persisted entry, which is all the diff reads.

No transaction boundary, writer ownership, publication fencing, schema or
persisted representation changes. The revalidation reader lives in its own
module because the entry store is at its max-lines limit.

AI-assisted (Claude Code); measured, tested and reviewed by the author.
@clawsweeper

clawsweeper Bot commented Sep 2, 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.

@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 5, 2026, 7:15 PM ET / 23:15 UTC.

ClawSweeper review

What this changes

Reuse the committed session entry for identity notifications, avoiding an extra saved-prompt decode, with regression coverage for both SQLite patch APIs.

Merge readiness

⛔ Blocked before merge - 1 item remains

The optimization remains useful on current main, and the new standalone runtime evidence resolves the previous proof blocker. No actionable correctness or security defects were found.

Priority: P2
Reviewed head: 7bacafe8faac1d693ed1d014ebc45523a4267b55

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, well-supported optimization with meaningful runtime evidence and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The standalone built SDK exercises the changed session-patch owner through real SQLite, showing thirty decodes, five correct identity replacements, preserved prompt bytes, and successful reopened SDK and fresh CLI reads on the verified head tree; this satisfies the previous runtime-proof request.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The standalone built SDK exercises the changed session-patch owner through real SQLite, showing thirty decodes, five correct identity replacements, preserved prompt bytes, and successful reopened SDK and fresh CLI reads on the verified head tree; this satisfies the previous runtime-proof request.
Evidence reviewed 9 items Verified introduced change: The local merge-base-to-head diff matches the supplied introduction evidence: the production change replaces only the post-write identity read; preparation, commit checks, callback ordering, and maintenance remain intact.
Still necessary on main: Fetched main retains readSessionIdentitySnapshot after writeSessionEntry. The production file has no differences between the pinned base and fetched main. No supplied merged PR implements this remaining optimization.
Writer and observer contract: writeSessionEntry validates identity, rereads canonical provenance, writes the normalized entry, and returns that entry. Identity publication consumes only session IDs and map keys, so participant hydration and another payload decode are unnecessary.
Findings None None.
Security None None.

How this fits together

OpenClaw's session store persists session updates from runtime and plugin callers. After committing an update, it publishes identity changes to lifecycle observers and schedules maintenance.

flowchart TD
 A[Runtime or plugin update] --> B[Prepare session patch]
 B --> C[Revalidate current session]
 C --> D[Canonical SQLite writer]
 D --> E[Reuse committed identity]
 E --> F[Notify lifecycle observers]
 F --> G[Schedule maintenance]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +1, Tests +61. Total +62 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 2 1 +1
Tests 1 62 1 +61
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 64 2 +62

Review metrics

Metric Value Why it matters
Saved-prompt decoding 40 → 30 decodes per 10 patches The supplied baseline and standalone after-fix evidence establish reduced decoding work without claiming a whole-Gateway throughput improvement.

Stored data model

Persistent data-model change detected: serialized state: src/config/sessions/session-accessor.sqlite-entry.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Retain the canonical writer and its revalidation guarantees while eliminating the redundant identity-publication read.

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

Yes: current main visibly rereads and decodes the entry after the canonical writer returns it, and the supplied baseline regression records forty decodes across ten updates. This review verified the source path without executing it.

Is this the best way to solve the issue?

Yes: reusing the writer's committed result removes the redundant work without weakening provenance checks, changing stored representations, or introducing a parallel cache.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The standalone built SDK exercises the changed session-patch owner through real SQLite, showing thirty decodes, five correct identity replacements, preserved prompt bytes, and successful reopened SDK and fresh CLI reads on the verified head tree; this satisfies the previous runtime-proof request.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The standalone built SDK exercises the changed session-patch owner through real SQLite, showing thirty decodes, five correct identity replacements, preserved prompt bytes, and successful reopened SDK and fresh CLI reads on the verified head tree; this satisfies the previous runtime-proof request.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a bounded session-store performance repair with preserved persistence and notification behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The standalone built SDK exercises the changed session-patch owner through real SQLite, showing thirty decodes, five correct identity replacements, preserved prompt bytes, and successful reopened SDK and fresh CLI reads on the verified head tree; this satisfies the previous runtime-proof request.
  • proof: sufficient: Contributor real behavior proof is sufficient. The standalone built SDK exercises the changed session-patch owner through real SQLite, showing thirty decodes, five correct identity replacements, preserved prompt bytes, and successful reopened SDK and fresh CLI reads on the verified head tree; this satisfies the previous runtime-proof request.

Evidence

What I checked:

  • Verified introduced change: The local merge-base-to-head diff matches the supplied introduction evidence: the production change replaces only the post-write identity read; preparation, commit checks, callback ordering, and maintenance remain intact. (src/config/sessions/session-accessor.sqlite-entry.ts:528, 7bacafe8faac)
  • Still necessary on main: Fetched main retains readSessionIdentitySnapshot after writeSessionEntry. The production file has no differences between the pinned base and fetched main. No supplied merged PR implements this remaining optimization. (src/config/sessions/session-accessor.sqlite-entry.ts:528, 3f946f93da4e)
  • Writer and observer contract: writeSessionEntry validates identity, rereads canonical provenance, writes the normalized entry, and returns that entry. Identity publication consumes only session IDs and map keys, so participant hydration and another payload decode are unnecessary. (src/config/sessions/session-accessor.sqlite-entry-store.ts:500, 7bacafe8faac)
  • Focused regression coverage: Both entry and lifecycle-target cases retain the saved prompt and require five identity changes across ten patches while bounding payload decodes at thirty. The supplied validation reports forty decodes on the pinned baseline and sixty-five passing row/conformance tests after the repair. This review did not execute contributor code. (src/config/sessions/session-accessor.sqlite-session-row.test.ts:41, 7bacafe8faac)
  • Standalone production-runtime evidence: The captured body and perf(sessions): reuse committed identity after entry patches #136361 (comment) report a built public SDK run in a separate Node 24.20 process using temporary configuration and real SQLite: ten updates, thirty full-prompt decodes, five correct replacements, all 16,407 prompt bytes retained, unchanged schema, reopened reads, and a fresh CLI read of the final identity. The visible probe calls the SDK entrypoint that delegates to the changed owner. Its trailing script text is truncated, but the recorded results and relevant operations are present; no embedded script was executed. (src/plugin-sdk/session-store-runtime.ts:466, 7bacafe8faac)
  • Proof source identity and review continuity: HEAD's tree is 6ec1f7bc11405b764e7bd438f56fca27ce45878c, matching the standalone proof's declared source tree. The prior review covered this same head and requested runtime evidence, now supplied. Earlier fixture concerns are resolved by synthetic identifiers and removal of the former cache implementation. (7bacafe8faac)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • obviyus: 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 (5 earlier review cycles)
  • reviewed 2026-09-02T14:30:53.095Z sha 6f20abc :: needs changes before merge. :: [P2] Use synthetic model IDs in the new test fixtures
  • reviewed 2026-09-02T18:56:46.988Z sha 6f20abc :: needs changes before merge. :: [P2] Use synthetic model IDs in the new fixtures
  • reviewed 2026-09-05T22:05:14.833Z sha 7bacafe :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-05T22:10:47.447Z sha 7bacafe :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-05T22:25:30.532Z sha 7bacafe :: needs real behavior proof before merge. :: none

@LiuwqGit

LiuwqGit commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

FYI: I independently implemented the same fix (decode once at preparation + raw-row fingerprint revalidation at the commit edge) in #136371 and closed it as a duplicate in favor of this earlier, author-owned PR. No action needed.

@openclaw-barnacle openclaw-barnacle Bot closed this Sep 2, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Sep 2, 2026
@openclaw-barnacle openclaw-barnacle Bot closed this Sep 2, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Sep 2, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 2, 2026
@steipete steipete self-assigned this Sep 5, 2026
Use the canonical writer result for identity publication instead of decoding
saved prompts again. Preserve preparation, commit revalidation, the writer's
provenance read, callback ordering, and all persisted representations.

Both SQLite patch APIs now stay within three saved-prompt decodes per write;
65 owner and conformance tests pass. This narrows the original optimization
without introducing raw-row cache state or changing callback contracts.

Co-authored-by: Tran Quang <[email protected]>
@steipete steipete changed the title perf: SQLite session-entry patches decode the session row four times per write, costing ~9% gateway throughput at 16 concurrent agents perf(sessions): reuse committed identity after entry patches Sep 5, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Sep 5, 2026
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

The current head narrows this to the redundant identity-publication decode: the canonical writer already owns the session ID being published. It keeps full commit revalidation, fresh writer provenance, and deferred maintenance. The raw-row cache and its separate test file are removed; the replacement tests use synthetic session identifiers in the existing SQLite owner suite.

Both prior rank-up items are addressed: current main is integrated with the maintenance path preserved, and the release-like model fixtures are gone. The actual SQLite regression fails on the pinned main with 40 saved-prompt decodes for ten writes, then passes the 30-decode bound after the repair. All 65 row/conformance tests pass. The updated PR body distinguishes this proof from a whole-Gateway throughput claim; exact-head CI is still pending.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 5, 2026
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

The requested standalone runtime proof is complete on the PR's exact source tree. This uses the built public plugin SDK in a separate production Node process with normal temporary configuration and a real SQLite store; no Vitest or production-owner mocks. The observer only records the runtime's existing identity notifications. The normal CLI then reads the persisted result in a fresh process.

{
  "sourceTree": "6ec1f7bc11405b764e7bd438f56fca27ce45878c",
  "prHead": "7bacafe8faac1d693ed1d014ebc45523a4267b55",
  "runtime": "built plugin SDK in standalone Node process; no Vitest or mocked owners",
  "node": "v24.20.0",
  "patches": 10,
  "savedPromptBytes": 16407,
  "fullSavedPromptDecodes": 30,
  "identities": [
    {
      "kind": "replace",
      "previous": "runtime-seed",
      "current": "runtime-generation-0"
    },
    {
      "kind": "replace",
      "previous": "runtime-generation-0",
      "current": "runtime-generation-1"
    },
    {
      "kind": "replace",
      "previous": "runtime-generation-1",
      "current": "runtime-generation-2"
    },
    {
      "kind": "replace",
      "previous": "runtime-generation-2",
      "current": "runtime-generation-3"
    },
    {
      "kind": "replace",
      "previous": "runtime-generation-3",
      "current": "runtime-generation-4"
    }
  ],
  "persistedAndReopenedSessionId": "runtime-generation-4",
  "savedPromptPreserved": true,
  "schemaUnchanged": true,
  "userVersion": 19,
  "instrumentedElapsedMs": 28.220416000000114,
  "processRssBytes": 403259392,
  "freshCli": {
    "count": 1,
    "key": "agent:main:runtime-identity-proof",
    "sessionId": "runtime-generation-4"
  }
}

The schema comparison and fresh reads also confirm the data-model flag is not applicable to this change: no schema, row binding, serializer, or persisted representation changes. The native SDK/CLI proof complements the 65 passing owner/conformance tests and green exact-head CI.

Standalone runtime probe (synthetic data only)

After pnpm build sourcePerformance, run the following using a temporary HOME, OPENCLAW_STATE_DIR, and OPENCLAW_CONFIG_PATH with a normal main-agent configuration, then inspect it with pnpm --silent openclaw sessions --agent main --json --limit all.

import assert from 'node:assert/strict';
import { createHash } from 'node:crypto';
import fs from 'node:fs';
import path from 'node:path';
import { DatabaseSync } from 'node:sqlite';
import { pathToFileURL } from 'node:url';

const root = process.cwd();
const sdk = await import(pathToFileURL(path.join(root, 'dist/plugin-sdk/session-store-runtime.js')).href);
const sessionKey = 'agent:main:runtime-identity-proof';
const prompt = 'runtime-identity-proof:' + 'x'.repeat(16_384);
const storePath = path.join(process.env.OPENCLAW_STATE_DIR, 'agents/main/agent/openclaw-agent.sqlite');
const scope = { agentId: 'main', sessionKey, storePath };
const stamp = Date.now();
await sdk.upsertSessionEntry({ ...scope, entry: {
  sessionId: 'runtime-seed', updatedAt: stamp, createdVia: 'operator', createdAt: stamp,
  label: 'Runtime identity proof', skillsSnapshot: { prompt, skills: [] },
} });
const inspect = () => {
  const db = new DatabaseSync(storePath, { readOnly: true });
  try {
    const row = db.prepare('SELECT current_session_id, entry_json FROM session_nodes WHERE session_key = ?').get(sessionKey);
    const schema = db.prepare("SELECT type, name, tbl_name, sql FROM sqlite_schema WHERE name NOT LIKE 'sqlite_%' ORDER BY type, name").all();
    return {
      row,
      schemaSha256: createHash('sha256').update(JSON.stringify(schema)).digest('hex'),
      userVersion: db.prepare('PRAGMA user_version').get().user_version,
    };
  } finally { db.close(); }
};
const before = inspect();
const identities = [];
const listeners = globalThis[Symbol.for('openclaw.sessionIdentityMutationListeners')];
assert(listeners instanceof Set, 'built runtime identity observer registry exists');
const observe = event => {
  if (event.current?.sessionKeys.includes(sessionKey)) {
    identities.push({ kind: event.kind, previous: event.previous.sessionId, current: event.current.sessionId });
  }
};
listeners.add(observe);
const realParse = JSON.parse;
let decodes = 0;
JSON.parse = function(text, reviver) {
  const value = realParse(text, reviver);
  if (value && value.skillsSnapshot?.prompt === prompt && typeof value.sessionId === 'string') decodes++;
  return value;
};
const started = performance.now();
try {
  for (let index = 0; index < 10; index++) {
    const sessionId = `runtime-generation-${Math.floor(index / 2)}`;
    const result = await sdk.patchSessionEntry({ ...scope, skipMaintenance: true,
      update: entry => {
        assert.equal(entry.skillsSnapshot.prompt, prompt);
        return { sessionId, updatedAt: stamp + index + 1 };
      },
    });
    assert.equal(result.sessionId, sessionId);
    assert.equal(result.skillsSnapshot.prompt, prompt);
  }
} finally {
  JSON.parse = realParse;
  listeners.delete(observe);
}
const elapsedMs = performance.now() - started;
assert.equal(decodes, 30);
assert.deepEqual(identities.map(x => x.current), Array.from({ length: 5 }, (_, n) => `runtime-generation-${n}`));
assert(identities.every(x => x.kind === 'replace'));
const after = inspect();
assert.equal(after.schemaSha256, before.schemaSha256);
assert.equal(after.userVersion, before.userVersion);
assert.equal(after.row.current_session_id, 'runtime-generation-4');
assert.equal(realParse(after.row.entry_json).skillsSnapshot.prompt, prompt);
const reopened = sdk.getSessionEntry(scope);
assert.equal(reopened.sessionId, 'runtime-generation-4');
assert.equal(reopened.skillsSnapshot.prompt, prompt);
console.log(JSON.stringify({
  runtime: 'built plugin SDK in standalone Node process; no Vitest or mocked owners',
  node: process.version, patches: 10, savedPromptBytes: Buffer.byteLength(prompt),
  fullSavedPromptDecodes: decodes, identities, persistedAndReopenedSessionId: reopened.sessionId,
  savedPromptPreserved: true, schemaUnchanged: true, userVersion: after.userVersion,
  instrumentedElapsedMs: elapsedMs, processRssBytes: process.memoryUsage().rss,
}, null, 2));

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 5, 2026
@steipete
steipete merged commit 4a5809d into openclaw:main Sep 5, 2026
244 of 246 checks passed
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 5, 2026
* origin/main: (95 commits)
  perf(build): avoid unrelated gateway artifact scans (#127757)
  fix(update): deliver terminal progress after long updates (#139289)
  fix(ui): show session hover cards for local chat URLs (#139384)
  perf(ui): reuse unchanged transcript key snapshots (#139400)
  fix(ui): make subagent sessions view-only (#139381)
  fix: open agent state on SQLite builds without extensions (#139487)
  perf(skills): detach cached metadata from source strings (#139478)
  fix(ui): show primary user in multi-agent profile hero (#136736)
  perf(sessions): stop decoding the session row four times per SQLite entry patch (#136361)
  refactor(exec): share package-manager option scans (#139482)
  fix(ci): authorize frozen mobile release candidates (#139441)
  fix: avoid session deletion slowdown in large session stores (#139467)
  perf(gateway): reuse node invocation idle timers (#139354)
  fix(auth): preserve selected profiles across plugin scopes (#139413)
  fix(discord): retain voice input until transcription completes (#139484)
  fix(agents): name Gateway storage failures in run-failure copy (#139409)
  fix: keep subagent checks responsive in large session stores (#139450)
  fix(memory): index notes when optional embeddings cannot start (#139463)
  fix: refresh pending approvals when reopening chat (#139457)
  fix(tooling): preserve Git hook choices during install (#139461)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 6, 2026
…ntry patch (openclaw#136361)

patchSqliteSessionEntrySnapshot read and JSON-decoded the session row at
preparation, again inside the write transaction to revalidate (then
JSON.stringify-compared both copies), a third time inside writeSessionEntry for
the canonical previous entry, and a fourth time after the write for the identity
diff, running the participants projection query on every decode. A streamed
reply turn issues about eleven such patches, so with a prod-shaped ~17 KB
entry_json the session store took 29% of a saturated gateway main thread on
2026.8.2 against 3.6% for the JSON store on 2026.7.1-2.

Snapshot rows now carry the raw persisted row they were decoded from. At commit,
readUnchangedLifecycleTargetSnapshot re-reads the raw rows for exactly the keys
the snapshot reader consults and reuses the prepared snapshot when every column
is identical; any difference falls back to the original full re-decode and deep
compare, so conflict detection is unchanged. writeSessionEntry accepts the
canonical previous entry the commit already holds, and the post-commit identity
map is built from the persisted entry, which is all the diff reads.

No transaction boundary, writer ownership, publication fencing, schema or
persisted representation changes. The revalidation reader lives in its own
module because the entry store is at its max-lines limit.

AI-assisted (Claude Code); measured, tested and reviewed by the author.

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: Tran Quang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants