Skip to content

refactor: add public transcript identity API#89261

Closed
jalehman wants to merge 9 commits into
mainfrom
clawdbot-d02.1.9.1.20/31b-public-sdk-transcript-identity-api
Closed

refactor: add public transcript identity API#89261
jalehman wants to merge 9 commits into
mainfrom
clawdbot-d02.1.9.1.20/31b-public-sdk-transcript-identity-api

Conversation

@jalehman

@jalehman jalehman commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

What

Adds the public SDK transcript identity API used by Path 3 session/transcript seam work. The PR introduces storage-neutral transcript identity and memory-hit key helpers so plugin and memory consumers can stop deriving transcript identity from file basenames or sessionFile paths.

Refs #88838. Stacked on #89201.

Why

The SQLite migration needs plugin-facing transcript consumers to address transcript state by stable session identity before the storage backend can change. File-path and basename matching are not portable to SQLite, but the compatibility surface still needs an additive SDK path for existing callers.

Changes

  • Add transcript identity SDK subpath
  • Add memory hit key helpers
  • Update session transcript hit mapping
  • Document SDK runtime surface
  • Update SDK export metadata
  • Add focused identity tests

Changes Walkthrough

File Change
src/plugin-sdk/session-transcript-runtime.ts Adds public transcript identity helpers
src/plugin-sdk/session-transcript-hit.ts Routes hit lookup through identity keys
src/config/sessions/session-accessor.ts Exposes runtime transcript target resolution
src/config/sessions/transcript-runtime-state.ts Adds transcript runtime state contract
docs/plugins/sdk-runtime.md Documents transcript identity API
docs/plugins/sdk-subpaths.md Lists new SDK subpath
scripts/lib/plugin-sdk-entrypoints.json Adds SDK entrypoint metadata
docs/.generated/plugin-sdk-api-baseline.sha256 Updates public API baseline

Testing

  • Focused transcript identity/runtime tests were run by the implementation thread.
  • SDK export and API baseline checks were run by the implementation thread.
  • This PR was opened as draft for stack review; final proof should be refreshed before moving out of draft.

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

clawsweeper Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 19, 2026, 4:18 AM ET / 08:18 UTC.

Summary
The branch adds a public openclaw/plugin-sdk/session-transcript-runtime SDK subpath with transcript identity and memory-hit helpers, SDK docs/export metadata, and focused tests.

PR surface: Source +825, Tests +579, Docs +3, Config +4, Generated 0, Other +4. Total +1415 across 20 files.

Reproducibility: yes. Source inspection shows the public reader delegates to a parse-all loader, and the public identity helper delegates to a target resolver whose callee can persist session metadata; I did not run tests because this was a read-only cleanup review.

Review metrics: 1 noteworthy metric.

  • Public SDK subpaths: 1 added. A new openclaw/plugin-sdk export becomes a third-party compatibility contract once released.

Stored data model
Persistent data-model change detected: serialized state: src/config/sessions/session-accessor.test.ts, serialized state: src/config/sessions/session-accessor.ts, serialized state: src/config/sessions/store.ts, serialized state: src/config/sessions/transcript-append.ts, serialized state: src/gateway/session-compaction-checkpoints.ts, serialized state: src/plugin-sdk/session-transcript-hit.test.ts, and 9 more. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #88838
Summary: This PR is one implementation slice in the canonical Path 3 session/transcript SQLite migration stack; related PRs are prerequisites or follow-ups, not replacements for this public SDK contract.

Members:

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

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🦪 silver shellfish
Result: blocked until real behavior proof is added.

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

Rank-up moves:

  • [P1] Add redacted real plugin/runtime proof for transcript identity resolution and event reads, with private details removed.
  • [P1] Make public identity resolution read-only and add focused regression coverage.
  • Make public transcript reads skip malformed JSONL rows and refresh SDK export/API checks on the final head.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body lists tests and implementation-thread checks but no redacted real plugin/runtime output, terminal transcript, logs, or artifact showing transcript identity resolution and event reads after the patch; add proof to the PR body so a fresh ClawSweeper review can re-run, or ask a maintainer to comment @clawsweeper re-review if it does not trigger automatically. 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.

Risk before merge

  • [P1] Publishing the new openclaw/plugin-sdk/session-transcript-runtime subpath makes the identity-only shape a third-party plugin compatibility contract after release.
  • [P2] The current identity/read implementation can still mutate session metadata or reject otherwise recoverable transcript history until the read-only and malformed-row fixes are folded in.
  • [P1] The PR is draft/protected and lacks real behavior proof; final review needs a refreshed branch and SDK export/API checks on the final head.

Maintainer options:

  1. Fix Read Semantics Before Publishing (recommended)
    Make the public identity/read helpers read-only and malformed-line tolerant, then rerun SDK export/API checks and add real runtime proof on the refreshed head.
  2. Hold For API Direction
    Pause the draft while maintainers decide whether the identity-only public API should land before the target/writer helpers in the stack.
  3. Accept The Contract Deliberately
    Maintainers can choose to publish the identity-only surface as-is, but should explicitly own the plugin compatibility and session-state consequences before merge.

Next step before merge

  • [P1] Protected draft public SDK contract work needs maintainer API review and contributor proof; automation cannot choose the API direction or prove the contributor's runtime setup.

Security
Cleared: No concrete security or supply-chain concern was found in the TypeScript SDK/runtime helpers, tests, docs, package export metadata, or generated SDK hash update.

Review findings

  • [P2] Keep identity resolution read-only — src/plugin-sdk/session-transcript-runtime.ts:109
  • [P2] Skip malformed transcript lines in public reads — src/plugin-sdk/session-transcript-runtime.ts:125
Review details

Best possible solution:

Keep the stack PR open, make public identity reads non-mutating and malformed-row tolerant, then land only after maintainer API approval, branch refresh, and redacted real plugin/runtime proof.

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

Yes. Source inspection shows the public reader delegates to a parse-all loader, and the public identity helper delegates to a target resolver whose callee can persist session metadata; I did not run tests because this was a read-only cleanup review.

Is this the best way to solve the issue?

No, not as a final landing shape. The identity boundary is plausible for the SQLite migration, but the public SDK contract should use read-only identity resolution, tolerate malformed transcript rows, and have maintainer API approval plus real proof before publishing.

Full review comments:

  • [P2] Keep identity resolution read-only — src/plugin-sdk/session-transcript-runtime.ts:109
    resolveSessionTranscriptIdentity calls resolveSessionTranscriptRuntimeTarget, which can route through resolveAndPersistSessionFile and write sessionFile/updatedAt when a row lacks the current transcript path. A public identity read should not change session activity or create file-backed metadata; derive the identity read-only or use a read-only target resolver.
    Confidence: 0.85
  • [P2] Skip malformed transcript lines in public reads — src/plugin-sdk/session-transcript-runtime.ts:125
    readSessionTranscriptEvents exposes loadTranscriptEvents through a new public SDK subpath, but that loader parses every streamed JSONL line without catching failures. Existing transcript readers tolerate malformed rows, so one bad row can prevent plugins from reading later valid session history unless this public reader catches parse failures and continues.
    Confidence: 0.88

Overall correctness: patch is incorrect
Overall confidence: 0.89

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 86b24ac2b2fc.

Label changes

Label justifications:

  • P2: This is a normal-priority public SDK/session-transcript migration PR with compatibility impact but no standalone current production outage.
  • merge-risk: 🚨 compatibility: The diff adds a documented public plugin SDK subpath and package export that third-party plugins may adopt after release.
  • merge-risk: 🚨 session-state: The proposed identity/read path can touch session metadata and can reject recoverable transcript history until fixed.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body lists tests and implementation-thread checks but no redacted real plugin/runtime output, terminal transcript, logs, or artifact showing transcript identity resolution and event reads after the patch; add proof to the PR body so a fresh ClawSweeper review can re-run, or ask a maintainer to comment @clawsweeper re-review if it does not trigger automatically. 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.
Evidence reviewed

PR surface:

Source +825, Tests +579, Docs +3, Config +4, Generated 0, Other +4. Total +1415 across 20 files.

View PR surface stats
Area Files Added Removed Net
Source 10 828 3 +825
Tests 4 579 0 +579
Docs 2 3 0 +3
Config 1 4 0 +4
Generated 1 2 2 0
Other 2 4 0 +4
Total 20 1420 5 +1415

What I checked:

  • AGENTS policy applied: The plugin SDK guide treats this directory as the public contract between plugins and core, so adding a subpath is compatibility-sensitive review scope. (src/plugin-sdk/AGENTS.md:1, 86b24ac2b2fc)
  • Current main lacks the new public subpath: Current main lists session-store-runtime and session-transcript-hit, but no session-transcript-runtime package export or SDK entrypoint, so the central change is not already implemented. (package.json:982, 86b24ac2b2fc)
  • Latest release lacks the new public subpath: The latest release tag has session-store-runtime and session-transcript-hit, but not session-transcript-runtime, so this is not shipped behavior either. (package.json:957, 844f405ac1be)
  • PR adds a public package export: The PR head adds ./plugin-sdk/session-transcript-runtime to package.json, making this a public third-party plugin import surface once released. (package.json:952, f6d594959907)
  • Identity helper calls the runtime target resolver: The new public resolveSessionTranscriptIdentity delegates to resolveSessionTranscriptRuntimeTarget, even though the public API only returns identity fields. (src/plugin-sdk/session-transcript-runtime.ts:109, f6d594959907)
  • Runtime target resolution can persist session metadata: The resolver path can call resolveAndPersistSessionFile, which writes sessionFile and updatedAt to the session store when the target is missing or changed. (src/config/sessions/session-file.ts:46, 86b24ac2b2fc)

Likely related people:

  • jalehman: Authored this PR, the linked Path 3 tracker, and the merged runtime transcript identity/state prerequisite that this public SDK layer builds on. (role: active migration stack owner; confidence: high; commits: f6d594959907, 57aa52c1e33c, efa9a6110b4e; files: src/plugin-sdk/session-transcript-runtime.ts, src/config/sessions/session-accessor.ts, src/agents/embedded-agent-runner/transcript-runtime-state.ts)
  • jack-stormentswe: Authored the transcript streaming change that explicitly preserved malformed-line tolerance in the sibling readers this public helper should match. (role: original streaming helper contributor; confidence: medium; commits: 9654239af9f9; files: src/config/sessions/transcript-stream.ts, src/config/sessions/transcript.ts, src/gateway/session-compaction-checkpoints.ts)
  • steipete: Merged the transcript streaming/tolerance change and recently touched plugin SDK runtime documentation and transcript helper docs in the same area. (role: recent adjacent contributor and merger; confidence: medium; commits: 9654239af9f9, c74fd6f01540, feffb6d02ff8; files: src/config/sessions/transcript-stream.ts, src/plugin-sdk/session-transcript-hit.ts, docs/plugins/sdk-runtime.md)
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: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jun 2, 2026
@jalehman
jalehman force-pushed the clawdbot-d02.1.9.1.15.1/31b-transcript-identity-state-contract branch 2 times, most recently from a0e06d4 to 8432a1b Compare June 11, 2026 05:03
@jalehman
jalehman force-pushed the clawdbot-d02.1.9.1.15.1/31b-transcript-identity-state-contract branch 4 times, most recently from cb112eb to 57aa52c Compare June 15, 2026 19:00
Base automatically changed from clawdbot-d02.1.9.1.15.1/31b-transcript-identity-state-contract to main June 15, 2026 20:04
@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Jun 15, 2026
@jalehman

Copy link
Copy Markdown
Contributor Author

Superseded by #95030.

I rebuilt this slice together with #89262 on current main as one replacement draft PR because the public SDK transcript identity API and scoped target/read/write/publish/lock helpers are one coherent plugin-facing contract. Please review #95030 instead.

@jalehman jalehman closed this Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime 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 rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts size: XL 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