Skip to content

refactor: add transcript runtime identity contract#89201

Merged
jalehman merged 1 commit into
mainfrom
clawdbot-d02.1.9.1.15.1/31b-transcript-identity-state-contract
Jun 15, 2026
Merged

refactor: add transcript runtime identity contract#89201
jalehman merged 1 commit into
mainfrom
clawdbot-d02.1.9.1.15.1/31b-transcript-identity-state-contract

Conversation

@jalehman

@jalehman jalehman commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

What

Adds the canonical file-backed transcript runtime identity/state contract for Path 3.1b, building on the session accessor seam without adding SQLite storage, production storage flips, runtime dual-read/fallback, or doctor migration code.

Why

Path 3 needs a storage-neutral transcript identity/state contract before the SQLite implementation can replace file-backed runtime transcript state. This keeps normal runtime operations scoped by agent/session identity instead of raw sessionFile paths, while preserving explicit file-artifact boundaries until their owners migrate.

Changes

  • Adds SessionTranscriptRuntimeScope / target resolution
  • Adds runtime transcript state APIs
  • Adds runtime rewrite/truncation wrappers
  • Adds successor/checkpoint scoped wrappers
  • Preserves active file-artifact paths
  • Adds focused file-backed tests

Included scope:

  • File-backed storage-neutral transcript runtime scope/target.
  • Runtime transcript state read/persist/replace/existence/delete APIs.
  • Runtime rewrite, tool-result truncation, successor rotation, checkpoint leaf/snapshot wrappers.
  • Explicit active artifact exclusions where the caller already owns the live file.

Excluded scope:

  • SQLite adapter/schema/store modules.
  • Public SDK transcript API changes.
  • Plugin/memory artifact APIs.
  • Production storage flip or runtime wiring.
  • Doctor migration implementation.
  • Runtime dual-read or fallback behavior.

Follow-ups:

  • clawdbot-d02.1.9.1.21: SQLite side of the transcript identity/state adapter.
  • clawdbot-d02.1.9.1.20: public SDK transcript identity/API compatibility.
  • clawdbot-d02.1.9.1.23: plugin/memory transcript artifact APIs.
  • clawdbot-d02.1.9.1.15.3: remaining sessionFile artifact-boundary classification.

Refs #88838.

Testing

  • node scripts/run-vitest.mjs src/config/sessions/session-accessor.test.ts src/agents/embedded-agent-runner/transcript-runtime-state.test.ts src/agents/embedded-agent-runner/transcript-rewrite.test.ts src/agents/embedded-agent-runner/tool-result-truncation.test.ts src/agents/embedded-agent-runner/compaction-successor-transcript.test.ts src/gateway/session-compaction-checkpoints.test.ts
    • Passed: 75 tests across 3 shards.
  • oxfmt --check on touched files.
    • Passed.
  • git diff --check.
    • Passed.
  • .agents/skills/autoreview/scripts/autoreview --mode local.
    • Passed: no accepted/actionable findings.

Known proof gap:

  • Full node scripts/run-tsgo.mjs -p tsconfig.json --noEmit --pretty false was attempted and failed on unrelated existing extensions/copilot timestamp/baseDirectory and ui missing three errors, not on this slice.

Real Behavior Proof

Behavior addressed: transcript runtime identity contract plus gateway compaction checkpoint persistence after a real session exceeds practical context limits.
Real environment tested: live local OpenClaw gateway from the PR build on macOS 15.6.1 / Node 24.15.0, using session agent:main:pr89201-compaction-proof-20260615-172548.
Exact steps or command run after this patch: rebuilt the PR checkout with pnpm build, restarted the live gateway, sent a broad read-only PR-review prompt into the proof session to inflate context, then ran pnpm openclaw gateway call sessions.compact --params '{"key":"agent:main:pr89201-compaction-proof-20260615-172548"}' --json --timeout 600000.
Evidence after fix: gateway status reported Git @ 7ffe7061 for the tested PR build; sessions.compact returned ok: true, compacted: true, tokensBefore: 110131, tokensAfter: 104375, details.rounds: 1, and details.targetTokens: 193500; the session store then reported compactionCount: 2 and one persisted manual checkpoint 0cfef200-3600-49af-a6ab-3e79d8e81363 with matching pre/post session identity and post session file.
Observed result after fix: explicit gateway compaction completed and persisted a checkpoint for the active transcript identity without losing the session mapping.
What was not tested: rotated-successor transcript proof with agents.defaults.compaction.truncateAfterCompaction=true; a retry with that option returned already under target and did not create a successor transcript. The branch was then rebased cleanly onto upstream/main@55d1324c7d0d2146b16aaef9572b7177a710f881 as 57aa52c1e33c4c970e9273486f5069ca44572633; focused Vitest and autoreview were rerun on the prior clean rebase SHA, then the final moving-main rebase passed session-accessor boundary guard, oxfmt, and git diff check.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling 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 real behavior proof before merge. Reviewed June 15, 2026, 1:15 PM ET / 17:15 UTC.

Summary
The PR adds a file-backed runtime transcript scope/target contract, runtime transcript state helpers, scoped rewrite/truncation/compaction/checkpoint wrappers, and focused tests without flipping storage to SQLite.

PR surface: Source +371, Tests +266, Other +6. Total +643 across 14 files.

Reproducibility: not applicable. this is a staged refactor contract rather than a bug report with a failing reproduction. The useful checks are source review, focused file-backed tests, and maintainer review of the contract semantics.

Review metrics: 2 noteworthy metrics.

  • Runtime transcript state APIs: 7 added. These functions define the contract later storage slices must preserve for target resolution, read, persist, replace, existence, and delete behavior.
  • Storage backend flip: 0 SQLite adapters or runtime flips added. The PR intentionally keeps the change file-backed, so maintainers can review identity semantics separately from migration behavior.

Stored data model
Persistent data-model change detected: serialized state: src/agents/embedded-agent-runner/compaction-successor-transcript.test.ts, serialized state: src/agents/embedded-agent-runner/tool-result-truncation.test.ts, serialized state: src/agents/embedded-agent-runner/transcript-rewrite.test.ts, serialized state: src/config/sessions/session-accessor.test.ts, serialized state: src/config/sessions/session-accessor.ts, serialized state: src/gateway/session-compaction-checkpoints.test.ts, and 9 more. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🌊 off-meta tidepool
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:

  • none.

Risk before merge

  • [P1] The runtime transcript scope becomes the contract for later SQLite, SDK, and reader slices; wrong sessionKey, sessionId, or threadId semantics could mis-associate transcript state.
  • [P1] Several dependent open PRs are stacked on this contract, so a bad identity shape would propagate into later migration work.

Maintainer options:

  1. Confirm The Contract Then Land (recommended)
    Maintainers can land this after explicitly accepting the sessionKey/sessionId/threadId contract and normal required checks on the current head.
  2. Revise The Runtime Scope First
    If the identity fields are not the permanent Path 3 contract, adjust this slice before downstream SQLite, SDK, and reader PRs depend on it.
  3. Pause The Dependent Stack
    If Path 3’s transcript identity boundary is still unsettled, pause this PR and retarget dependent branches to the updated migration plan.

Next step before merge

  • [P1] The remaining action is maintainer contract approval for session identity semantics, not a mechanical repair.

Security
Cleared: No concrete security or supply-chain concern was found; the diff changes repo-local TypeScript, tests, and a boundary script without new dependencies, workflows, permissions, or secret handling.

Review details

Best possible solution:

Have maintainers approve the runtime identity contract and land this file-backed seam before dependent SQLite, SDK, and reader slices build on it.

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

Not applicable; this is a staged refactor contract rather than a bug report with a failing reproduction. The useful checks are source review, focused file-backed tests, and maintainer review of the contract semantics.

Is this the best way to solve the issue?

Yes, if maintainers accept the linked Path 3 plan: a file-backed identity seam is narrower than combining caller migration with the SQLite storage flip. It still needs human contract approval because downstream slices rely on this shape.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 8ded75628437.

Label changes

Label changes:

  • remove proof: sufficient: Current real behavior proof status is not_applicable, not sufficient.

Label justifications:

  • P2: This is normal-priority internal migration work with limited immediate user-facing blast radius but meaningful session-state implications.
  • merge-risk: 🚨 session-state: The diff changes transcript/session identity and mutation helpers that could mis-associate runtime transcript state if the contract is wrong.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer-labeled internal architecture slice is not subject to the external contributor real-behavior proof gate; focused tests and maintainer contract review are the relevant proof path.
Evidence reviewed

PR surface:

Source +371, Tests +266, Other +6. Total +643 across 14 files.

View PR surface stats
Area Files Added Removed Net
Source 6 410 39 +371
Tests 7 268 2 +266
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 6 0 +6
Total 14 684 41 +643

What I checked:

  • Repository policy applied: Root and scoped AGENTS.md were read; session state, migration seams, gateway helpers, scripts, and tests are compatibility-sensitive review areas for this PR. (AGENTS.md:24, 8ded75628437)
  • Current main does not already implement the contract: Current main has no runtime transcript scope/target module or helper symbols from this PR; the only transcript-runtime match is unrelated runtime plan policy typing. (8ded75628437)
  • PR head adds runtime transcript identity: The PR head adds SessionTranscriptRuntimeScope/Target plus separate write and read target resolution, keeping sessionFile as a file-backed implementation detail. (src/config/sessions/session-accessor.ts:88, 7ffe7061dccb)
  • PR head adds runtime transcript state facade: The new facade exposes target resolution, read, persist, replace, existence, and delete helpers over the resolved runtime transcript target. (src/agents/embedded-agent-runner/transcript-runtime-state.ts:30, 7ffe7061dccb)
  • PR head adds scoped mutation wrappers: The PR wraps transcript rewrite, tool-result truncation, successor rotation, and checkpoint snapshot reads around runtime transcript scope while leaving storage file-backed. (src/agents/embedded-agent-runner/transcript-rewrite.ts:383, 7ffe7061dccb)
  • Focused tests cover the key identity invariant: PR-head tests cover topic-session target alignment and missing-transcript probes that must not create session metadata. (src/config/sessions/session-accessor.test.ts:588, 7ffe7061dccb)

Likely related people:

  • jalehman: Live PR and related tracker history show this person carrying the Path 3 session/transcript identity stack; merged PR refactor: add session accessor seam with gateway consumer #90463 introduced the current session accessor seam that this PR extends. (role: feature stack owner and recent area contributor; confidence: high; commits: 7ffe7061dccb, fee584a07404, 58aa59eaf805; files: src/config/sessions/session-accessor.ts, src/agents/embedded-agent-runner/transcript-runtime-state.ts, src/gateway/session-compaction-checkpoints.ts)
  • osolmaz: The linked tracker discussion connects this migration to false transcript-takeover and message-loss clusters, providing maintainer context for why the session/transcript identity boundary matters. (role: adjacent behavior reporter; confidence: medium; files: src/agents/embedded-agent-runner/run/attempt.session-lock.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: 🦪 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. P2 Normal backlog priority with limited blast radius. 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:54
@jalehman
jalehman force-pushed the clawdbot-d02.1.9.1.15.1/31b-transcript-identity-state-contract branch from a5012a3 to a0e06d4 Compare June 4, 2026 21:54
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jun 4, 2026
@jalehman
jalehman force-pushed the clawdbot-9c3-ce2/session-accessor-gateway-entry branch from a13e0eb to 890d5e3 Compare June 4, 2026 22:37
@jalehman
jalehman force-pushed the clawdbot-9c3-ce2/session-accessor-gateway-entry branch from 890d5e3 to b496b4b Compare June 10, 2026 22:16
@jalehman
jalehman force-pushed the clawdbot-d02.1.9.1.15.1/31b-transcript-identity-state-contract branch from a0e06d4 to 8432a1b Compare June 11, 2026 05:03
@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
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 added 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: 🌊 off-meta tidepool PR readiness rating does not apply to this item. labels Jun 14, 2026
@jalehman
jalehman force-pushed the clawdbot-9c3-ce2/session-accessor-gateway-entry branch 2 times, most recently from c320249 to 9a55d1b Compare June 14, 2026 13:00
@jalehman
jalehman force-pushed the clawdbot-9c3-ce2/session-accessor-gateway-entry branch from 9a55d1b to 58aa59e Compare June 14, 2026 13:13
Base automatically changed from clawdbot-9c3-ce2/session-accessor-gateway-entry to main June 14, 2026 13:18
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts size: XL and removed size: M labels Jun 14, 2026
@jalehman
jalehman marked this pull request as ready for review June 14, 2026 13:25
@github-actions github-actions Bot added the dependencies-changed PR changes dependency-related files label Jun 14, 2026
@github-actions

github-actions Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Dependency graph guard cleared

This PR no longer has blocked dependency graph changes. A future dependency graph change requires a fresh /allow-dependencies-change comment after the guard blocks that new head SHA.

  • Current SHA: 57aa52c1e33c4c970e9273486f5069ca44572633

@jalehman
jalehman force-pushed the clawdbot-d02.1.9.1.15.1/31b-transcript-identity-state-contract branch from 8432a1b to efbe88d Compare June 14, 2026 14:24
@github-actions github-actions Bot removed the dependencies-changed PR changes dependency-related files label Jun 14, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: L and removed docs Improvements or additions to documentation size: XL labels Jun 14, 2026
@jalehman
jalehman force-pushed the clawdbot-d02.1.9.1.15.1/31b-transcript-identity-state-contract branch 2 times, most recently from 7ffe706 to cb112eb Compare June 15, 2026 18:58
@jalehman
jalehman force-pushed the clawdbot-d02.1.9.1.15.1/31b-transcript-identity-state-contract branch from cb112eb to 57aa52c Compare June 15, 2026 19:00
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. labels Jun 15, 2026
@jalehman
jalehman merged commit efa9a61 into main Jun 15, 2026
178 of 182 checks passed
@jalehman
jalehman deleted the clawdbot-d02.1.9.1.15.1/31b-transcript-identity-state-contract branch June 15, 2026 20:04
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 16, 2026
crh-code pushed a commit to crh-code/openclaw that referenced this pull request Jun 18, 2026
badgerbees pushed a commit to badgerbees/openclaw that referenced this pull request Jul 8, 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 gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts 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