Skip to content

refactor: route SDK session compatibility through seam#89203

Merged
jalehman merged 9 commits into
mainfrom
clawdbot-4a6/31b-sdk-whole-store-session-file-compat
Jun 19, 2026
Merged

refactor: route SDK session compatibility through seam#89203
jalehman merged 9 commits into
mainfrom
clawdbot-4a6/31b-sdk-whole-store-session-file-compat

Conversation

@jalehman

@jalehman jalehman commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

What

Routes the public plugin SDK and plugin runtime session-entry helpers through the file-backed session accessor seam while keeping legacy whole-store and session-file helpers as explicit deprecated compatibility exports.

Why

Path 3 needs SDK-facing session entry operations to stop depending on the mutable sessions.json whole-store shape before the SQLite storage flip, without breaking existing plugin contracts that still import whole-store or transcript-file helpers.

Changes

  • Route SDK entry helpers
  • Route runtime entry helpers
  • Preserve patch activity option
  • Keep deprecated file helpers
  • Refresh SDK API baseline
  • Document compatibility scope

Testing

  • node scripts/run-vitest.mjs src/plugin-sdk/session-transcript-hit.test.ts src/plugin-sdk/session-store-runtime.test.ts src/plugin-sdk/config-runtime.test.ts src/plugins/runtime/index.test.ts src/config/sessions/session-accessor.test.ts
  • pnpm tsgo:core
  • pnpm tsgo:core:test
  • pnpm plugin-sdk:api:gen
  • pnpm plugin-sdk:api:check
  • node scripts/run-oxlint.mjs <touched SDK/runtime files>
  • git diff --check
  • pnpm build
  • /Users/phaedrus/Projects/prompts/skills/autoreview/scripts/autoreview --mode local

Tracker: #88838

Scope notes:

  • Included: deprecated SDK whole-store/session-file compatibility and deprecation docs, plus entry-level SDK/runtime wrappers over the accessor seam.
  • Excluded: public SDK transcript identity API, runtime transcript identity internals, SQLite storage flip, doctor migration, and plugin/memory transcript APIs.
  • Follow-up dependency: clawdbot-d02.1.9.1.20/31b-public-sdk-transcript-identity-api should define the future public SDK transcript identity API before session-transcript-hit or plugin transcript helpers move off legacy basename/session-file matching.

Real behavior proof

Behavior addressed: SDK/runtime session-entry compatibility helpers still persist plugin-owned session entry updates after routing through the session accessor seam, while the live Gateway uses the rebased build.

Real environment tested: Local LaunchAgent Gateway from this checkout, OpenClaw 2026.6.8 (278c1f9), loopback port 18789, active-memory temporarily enabled for agent main and then restored from backup.

Exact steps or command run after this patch: pnpm build; pnpm openclaw gateway restart; curl -fsS http://127.0.0.1:18789/readyz; curl -fsS http://127.0.0.1:18789/healthz; pnpm openclaw agent --session-key agent:main:telegram:default:direct:path3-89203-compat-main --channel telegram --to path3-89203-compat-main --message "Reply exactly: path3 sdk channel proof" --model openai/gpt-5.4-mini --timeout 180 --json; targeted session-store read for that one key.

Evidence after fix: Gateway returned ready=true and healthz returned {"ok":true,"status":"live"}. The live agent turn completed with status: ok, runId: b3edc3c5-1868-4755-85e6-03b84e535bb0, sessionId: b6c4bc32-76ac-473a-83f7-c8be1c70894a, provider/model openai/gpt-5.4-mini, and assistant text path3 sdk channel proof.

Observed result after fix: The persisted proof session row existed with channel: telegram, delivery context { channel: telegram, to: path3-89203-compat-main }, and exactly one active-memory plugin debug entry: 🧩 Active Memory: status=unavailable elapsed=319ms query=recent. This entry is written by active-memory through api.runtime.agent.session.patchSessionEntry, proving the deprecated runtime session compatibility wrapper still writes through the accessor-backed path in a live Gateway turn.

What was not tested: A real external Telegram delivery was intentionally not sent (--deliver was omitted), and the future SQLite storage flip/doctor migration remains out of scope for this compatibility slice. Temporary proof config/session rows were cleaned up and the Gateway was restarted back to the original active-memory config.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation plugin: file-transfer size: M maintainer Maintainer-authored PR labels Jun 1, 2026
@clawsweeper

clawsweeper Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 18, 2026, 8:04 PM ET / 00:04 UTC.

Summary
The PR routes plugin SDK and injected runtime session-entry helpers through the session accessor seam while preserving deprecated whole-store and file-path compatibility exports.

PR surface: Source +314, Tests +273, Docs +2, Generated 0. Total +589 across 11 files.

Reproducibility: not applicable. this is a refactor/compatibility PR, not a bug report with a failing reproduction path. The PR body includes live Gateway proof, and the diff adds focused regression tests for the compatibility helpers.

Review metrics: 2 noteworthy metrics.

  • Plugin-facing session helper surface: 4 preferred entry helpers documented; 4 runtime and 5 SDK subpath compatibility helpers retained. The PR changes public plugin guidance and temporary SDK/runtime compatibility exports before the SQLite migration.
  • Write-confirmation threading: 1 option threaded through accessor-backed update wrappers. requireWriteSuccess affects whether critical compatibility writes fail closed when recovered store writes cannot be confirmed.

Stored data model
Persistent data-model change detected: migration/backfill/repair: docs/plugins/sdk-runtime.md, serialized state: src/config/sessions/session-accessor.ts, serialized state: src/plugin-sdk/session-store-runtime.test.ts, serialized state: src/plugin-sdk/session-store-runtime.ts, unknown-data-model-change: src/plugin-sdk/session-store-runtime.test.ts, unknown-data-model-change: src/plugin-sdk/session-store-runtime.ts, and 1 more. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #88838
Summary: This PR is a candidate SDK/runtime session compatibility implementation slice for the canonical session/transcript SQLite migration tracker.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Have the migration owner confirm the compatibility window and SQLite flip ordering before merge.

Risk before merge

  • [P1] Merging changes public plugin SDK and injected runtime session helpers that bundled and third-party plugins may call during upgrades, especially callers still using deprecated whole-store or file-path helpers.
  • [P1] The changed helpers mutate persisted session entries on the planned SQLite migration path, so maintainers should confirm ordering against the migration tracker to avoid stale, lost, or mis-associated session state.

Maintainer options:

  1. Land after migration-owner review (recommended)
    Have the session/transcript migration owner confirm that the deprecated whole-store/file-path compatibility window and accessor-backed write behavior match the SQLite flip sequence.
  2. Pause for transcript API stack
    If the pending transcript identity/target writer stack changes this public compatibility contract, pause this PR until that SDK shape is settled.

Next step before merge

  • [P2] The PR has a protected maintainer label and changes public plugin-facing session compatibility during a broader storage migration, so the remaining action is migration-owner review rather than an automated repair.

Security
Cleared: The diff does not change dependencies, workflows, lockfiles, secret handling, downloads, package metadata, or new code-execution paths.

Review details

Best possible solution:

Land this compatibility slice only after the session/transcript migration owner confirms the deprecation window and accessor-backed write semantics match the SQLite flip sequence.

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

Not applicable: this is a refactor/compatibility PR, not a bug report with a failing reproduction path. The PR body includes live Gateway proof, and the diff adds focused regression tests for the compatibility helpers.

Is this the best way to solve the issue?

Yes, with maintainer sequencing review: routing through the existing accessor seam is the narrow owner-boundary fix, and keeping the SQLite flip, doctor migration, and transcript identity APIs out of this PR avoids the monolithic migration failure mode tracked in the canonical issue.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 2a0e63d12bde.

Label changes

Label justifications:

  • P2: This is a bounded SDK/runtime migration slice with compatibility-sensitive plugin and session-state impact.
  • merge-risk: 🚨 compatibility: The PR changes public plugin SDK and injected runtime session helpers that existing plugins may call during upgrades.
  • merge-risk: 🚨 session-state: The PR changes persisted session entry write paths during the broader session/transcript storage migration.
  • 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 PR body includes after-fix live Gateway proof with health checks, an agent run, persisted session-row inspection, and a plugin debug entry written through the changed runtime session wrapper.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix live Gateway proof with health checks, an agent run, persisted session-row inspection, and a plugin debug entry written through the changed runtime session wrapper.
Evidence reviewed

PR surface:

Source +314, Tests +273, Docs +2, Generated 0. Total +589 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 5 352 38 +314
Tests 3 296 23 +273
Docs 2 4 2 +2
Config 0 0 0 0
Generated 1 2 2 0
Other 0 0 0 0
Total 11 654 65 +589

What I checked:

  • Repository policy applied: Root plus scoped plugin SDK, plugin runtime, and docs AGENTS.md files were read; the applicable guidance treats plugin SDK and session-state migration surfaces as compatibility-sensitive and protected-label items as maintainer-handled. (AGENTS.md:20, 2a0e63d12bde)
  • Live PR state: Live GitHub metadata shows the PR is open, contributor-authored, not draft, mergeable but unstable, and labeled maintainer, proof: sufficient, merge-risk: 🚨 compatibility, and merge-risk: 🚨 session-state; that blocks cleanup close and routes the remaining decision to maintainers. (16d684fd16d6)
  • Current main still has the older SDK facade shape: Current main directly re-exports SDK read helpers from session-accessor.js and mutation helpers from store.js, so the PR is not already implemented on main. (src/plugin-sdk/session-store-runtime.ts:3, 2a0e63d12bde)
  • PR head routes SDK wrappers through the seam: The PR head defines object-parameter SDK wrappers for get/list/read/patch/update/upsert and forwards them through the session accessor seam while keeping deprecated compatibility exports grouped. (src/plugin-sdk/session-store-runtime.ts:63, 16d684fd16d6)
  • PR head mirrors runtime facade wrappers: The injected plugin runtime facade uses the same accessor-backed wrapper pattern and continues exposing the existing runtime.agent.session helper names. (src/plugins/runtime/runtime-agent.ts:88, 16d684fd16d6)
  • Write-confirmation option is threaded through the accessor: The PR adds requireWriteSuccess to the accessor update options and forwards it into the file-backed update entry path, preserving fail-closed behavior for critical compatibility writes. (src/config/sessions/session-accessor.ts:272, 16d684fd16d6)

Likely related people:

  • jalehman: Authored this PR, the canonical migration tracker, the merged accessor-seam predecessor, and recent session-accessor migration commits on current main. (role: migration stack author / recent area contributor; confidence: high; commits: 16d684fd16d6, ef47dd610c87, 49e6f5a524bc; files: src/config/sessions/session-accessor.ts, src/plugin-sdk/session-store-runtime.ts, src/plugins/runtime/runtime-agent.ts)
  • Vincent Koc: Current checkout blame/log attributes the existing SDK/runtime facade files and nearby accessor option lines to a broad current-main refactor commit, though that appears less specific than the migration tracker history. (role: current-main line provenance; confidence: low; commits: 033162f20933; files: src/plugin-sdk/session-store-runtime.ts, src/plugins/runtime/runtime-agent.ts, src/config/sessions/session-accessor.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jun 1, 2026
@jalehman
jalehman force-pushed the clawdbot-9c3/session-accessor-seam branch from f18f99c to b39023f Compare June 4, 2026 20:31
@jalehman
jalehman changed the base branch from clawdbot-9c3/session-accessor-seam to clawdbot-9c3-ce2/session-accessor-gateway-entry June 4, 2026 21:41
@jalehman
jalehman force-pushed the clawdbot-4a6/31b-sdk-whole-store-session-file-compat branch 2 times, most recently from 7409398 to dfb367a Compare June 4, 2026 21:42
@jalehman
jalehman force-pushed the clawdbot-9c3-ce2/session-accessor-gateway-entry branch 2 times, most recently from 890d5e3 to b496b4b Compare June 10, 2026 22:16
@jalehman
jalehman force-pushed the clawdbot-4a6/31b-sdk-whole-store-session-file-compat branch from dfb367a to 4b52864 Compare June 11, 2026 05:04
@clawsweeper clawsweeper Bot added rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. and removed 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 Jun 11, 2026
@jalehman

Copy link
Copy Markdown
Contributor Author

Follow-up: the plugin SDK API baseline needs regeneration on this branch (pnpm plugin-sdk:api:gen) after the wave-1 rebase — plugin-sdk:api:check CI will fail until then. Pending a pnpm-capable environment; tracked in the wave-1 status on #88838.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. and removed rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. labels Jun 13, 2026
@jalehman
jalehman force-pushed the clawdbot-9c3-ce2/session-accessor-gateway-entry branch from 1e31abd to 094f9b5 Compare June 13, 2026 23:20
@clawsweeper clawsweeper Bot removed the status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. label Jun 14, 2026
@jalehman
jalehman force-pushed the clawdbot-4a6/31b-sdk-whole-store-session-file-compat branch from fad01c4 to 278c1f9 Compare June 18, 2026 23:18
@jalehman

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 18, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@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: 🧂 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 Jun 18, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. 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 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. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. labels Jun 19, 2026
@jalehman
jalehman merged commit f1cab04 into main Jun 19, 2026
212 of 229 checks passed
@jalehman
jalehman deleted the clawdbot-4a6/31b-sdk-whole-store-session-file-compat branch June 19, 2026 03:52
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 19, 2026
cxbAsDev pushed a commit to cxbAsDev/openclaw that referenced this pull request Jun 23, 2026
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 maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. plugin: file-transfer proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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