Skip to content

refactor: route auto-reply sessions through session seam#89124

Merged
jalehman merged 5 commits into
mainfrom
clawdbot-6f0/31b-auto-reply-agent-seam
Jun 15, 2026
Merged

refactor: route auto-reply sessions through session seam#89124
jalehman merged 5 commits into
mainfrom
clawdbot-6f0/31b-auto-reply-agent-seam

Conversation

@jalehman

@jalehman jalehman commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

What

Path 3 / PR 3.1b auto-reply/agent: routes auto-reply and agent runtime session writes through the 3.1a session accessor seam while preserving current file-backed behavior. Refs #88838.

Why

This moves the auto-reply/agent slice off direct session-store mutations before the SQLite storage flip, keeping caller adoption separate from storage implementation changes. The PR depends on the 3.1a seam base branch clawdbot-9c3/session-accessor-seam at be13ad13f8 and its seam commits including bb48e18ded, f6ae83451a, 0faccc0cfa, 5c38bb4be4, 2d9c5b65a3, and be13ad13f8.

Changes

  • Route agent runtime session writes through seam
  • Route auto-reply session updates through seam
  • Preserve file-backed behavior and current shapes
  • Keep transcript/file-semantic callers out of scope
  • No storage flip, runtime dual-read, or SQLite schema work
  • No blockers
Area Change
src/agents/command/* Moves command/session persistence to seam helpers
src/agents/embedded-agent-runner/* Routes embedded runtime session mutations through seam
src/auto-reply/reply/* Moves auto-reply run/session state updates to seam

Testing

  • Source branch clawdbot-6f0/31b-auto-reply-agent-seam at 582bdb04e7 (7bd273b08c + 582bdb04e7 on the 3.1a base).
  • File-backed proof on the source branch: node scripts/run-vitest.mjs over agent command/session and auto-reply runner/session tests passed 428 tests.
  • Disposable SQLite validation branch integration/sqlite-flip-auto-reply-agent at b1600517d6.
  • SQLite validation proof passed 439 tests across the same slice plus src/config/sessions/session-accessor.conformance.test.ts and src/auto-reply/reply/sqlite-session-accessor.validation.test.ts.
  • Validation branch cherry-picked 3b9353414e (3.1a read-scope fix), 59a590e825 (3.2 SQLite foundation), and c221e48beb (3.2 read-scope fix) with no storage fallback or dual-read wiring.
  • pnpm exec oxfmt --check src/config/sessions/session-accessor.ts src/auto-reply/reply/sqlite-session-accessor.validation.test.ts
  • node scripts/run-oxlint.mjs src/config/sessions/session-accessor.ts src/auto-reply/reply/sqlite-session-accessor.validation.test.ts
  • pnpm tsgo:core
  • pnpm tsgo:core:test
  • git diff --check

Real behavior proof

Behavior addressed: PR #89124 routes auto-reply sessions through the session-accessor seam after the #90463 rebase, preserving the narrow auto-reply slice.

Real environment tested: Managed live OpenClaw Gateway on this machine, running PR head f0a985f after pnpm build and LaunchAgent Gateway restart. The CLI reported OpenClaw 2026.6.2 (f0a985f), the Gateway was listening on loopback port 18789, and the agent used the live openai/gpt-5.5 provider.

Exact steps or command run after this patch: Ran pnpm openclaw agent against the managed Gateway with session key agent:main:pr89124-live-gateway-proof-20260615T2017Z and prompt "Reply exactly with PR89124_LIVE_OK and nothing else." Then ran delivered channel proofs with pnpm openclaw agent --deliver for the configured Discord channel and configured Telegram group topic.

Evidence after fix: Gateway run 54cde5c1-d306-4a71-80eb-3d8a8b18d1b6 completed in session 5676b0d9-3548-4b64-aa4a-2df6dcb571bd with output PR89124_LIVE_OK; the persisted session row reported status done, modelProvider openai, model gpt-5.5, totalTokensFresh true, and a transcript file exists. Discord delivery run 465d5103-b947-4500-ad0c-584a90f8526e completed in session 6e8d619d-10c7-4bef-b866-4f172ed68ee2 with payload PR89124_DISCORD_OK., deliveryStatus sent, succeeded true. Telegram delivery run d575b759-5865-47a4-a5f6-3776ecd99dce completed in session 6a240460-5e6b-48c0-a52d-207f5fcc1f6d with payload PR89124_TELEGRAM_OK, deliveryStatus sent, succeeded true.

Observed result after fix: The real managed Gateway accepted the PR build, completed the Gateway agent turn, and sent real outbound replies through both the Discord and Telegram channel adapters.

What was not tested: I did not prove inbound human-authored Discord or Telegram trigger messages in this pass; the channel proof used Gateway-delivered outbound replies to already configured live channel targets.

@clawsweeper

clawsweeper Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed June 15, 2026, 4:54 PM ET / 20:54 UTC.

Summary
Routes auto-reply and agent runtime session persistence paths through the session accessor seam while preserving file-backed storage behavior.

PR surface: Source +228, Tests +405, Other +57. Total +690 across 35 files.

Reproducibility: not applicable. This is a refactor PR, and the review is based on source inspection plus the provided live Gateway proof rather than a standalone bug reproduction.

Review metrics: 2 noteworthy metrics.

  • Session write ratchet: 21 migrated write files. The PR expands CI enforcement for files that should no longer call legacy session-store writers, so the writer set must be complete before merge.
  • Merge state: CONFLICTING / DIRTY. Maintainers need a rebase before the final merge result and refreshed checks can be trusted.

Stored data model
Persistent data-model change detected: database schema: src/config/sessions/store.pruning.test.ts, serialized state: src/agents/command/attempt-execution.shared.ts, serialized state: src/agents/command/session-store.test.ts, serialized state: src/agents/command/session-store.ts, serialized state: src/auto-reply/reply/abort-cutoff.runtime.test.ts, serialized state: src/auto-reply/reply/agent-runner.ts, and 15 more. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦞 diamond lobster
Patch quality: 🦐 gold shrimp
Result: needs maintainer review before merge.

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

Rank-up moves:

  • [P2] Add saveSessionStore to the write-boundary guard and focused test coverage.
  • Rebase on current main, resolve conflicts, and refresh the affected checks.
  • [P2] Keep maintainer review focused on session-state compatibility before merge.

Risk before merge

  • [P1] The branch is currently CONFLICTING / DIRTY against current main, so maintainers need a rebase before the final merge result and CI evidence are trustworthy.
  • [P1] The write-boundary guard omits saveSessionStore, allowing a direct whole-store save to slip back into migrated write files without failing the ratchet.
  • [P1] Session persistence routing is compatibility- and session-state-sensitive; the live proof is positive, but inbound human-authored channel trigger behavior was not covered.

Maintainer options:

  1. Rebase and complete the writer ratchet (recommended)
    Resolve the current-main conflicts, add saveSessionStore to the write-boundary guard and test, then rerun the affected boundary and session checks before merge.
  2. Accept the staged migration risk
    A maintainer can explicitly accept the remaining compatibility/session-state risk after the branch is rebased and the guard gap is fixed.
  3. Pause under the migration tracker
    If the session SQLite sequencing is still moving, keep this PR open but paused until the tracker is ready for the next caller-adoption slice.

Next step before merge

  • [P2] Manual review is appropriate because the PR is conflict-dirty, has a protected maintainer label, and needs maintainer acceptance of compatibility/session-state risk after the narrow guard fix.

Security
Cleared: No concrete security or supply-chain regression was found in the TypeScript session-runtime, test, and local boundary-check script changes.

Review findings

  • [P2] Block direct saveSessionStore writes — scripts/check-session-accessor-boundary.mjs:26-30
Review details

Best possible solution:

Rebase on current main, add saveSessionStore to the writer guard and focused test, refresh affected checks, then merge only after maintainer acceptance of the staged session-state migration risk.

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

Not applicable. This is a refactor PR, and the review is based on source inspection plus the provided live Gateway proof rather than a standalone bug reproduction.

Is this the best way to solve the issue?

Yes on direction, not yet on merge readiness. The accessor seam is the right owner boundary for this migration slice, but the write guard and current-main conflicts need to be fixed first.

Full review comments:

  • [P2] Block direct saveSessionStore writes — scripts/check-session-accessor-boundary.mjs:26-30
    migratedSessionAccessorWriteFiles is protected by legacyWriterNames, but that set omits saveSessionStore even though it is a direct whole-store writer. A migrated file could reintroduce a direct save and this ratchet would still pass; include saveSessionStore here and add the matching write-guard test case.
    Confidence: 0.88

Overall correctness: patch is incorrect
Overall confidence: 0.86

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body and comments include copied live Gateway output for the reviewed head, including a real agent turn plus live Discord and Telegram delivery runs; inbound human-triggered channel messages remain an untested gap, not a missing-proof blocker.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P2: This is a normal-priority internal session-state migration slice with limited immediate user-facing blast radius but real upgrade sensitivity.
  • merge-risk: 🚨 automation: The diff changes the session-accessor boundary guard that CI uses to ratchet migrated files away from legacy store access.
  • merge-risk: 🚨 compatibility: The PR changes session persistence access paths that current file-backed behavior and the planned SQLite upgrade path depend on.
  • merge-risk: 🚨 session-state: The diff changes session-entry read/write paths across agent and auto-reply runtime code where stale or mis-associated state would affect runs.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: 🛠️ actively grinding: The PR author has acted after the latest ClawSweeper review and work remains. Sufficient (live_output): The PR body and comments include copied live Gateway output for the reviewed head, including a real agent turn plus live Discord and Telegram delivery runs; inbound human-triggered channel messages remain an untested gap, not a missing-proof blocker.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body and comments include copied live Gateway output for the reviewed head, including a real agent turn plus live Discord and Telegram delivery runs; inbound human-triggered channel messages remain an untested gap, not a missing-proof blocker.
Evidence reviewed

PR surface:

Source +228, Tests +405, Other +57. Total +690 across 35 files.

View PR surface stats
Area Files Added Removed Net
Source 27 519 291 +228
Tests 7 455 50 +405
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 69 12 +57
Total 35 1043 353 +690

What I checked:

  • Repository policy applied: Root AGENTS.md was read fully; its deep-review, session-state compatibility, storage-migration, and protected-label guidance applies to this PR. (AGENTS.md:8, efa9a6110b4e)
  • Scoped guides read: The scripts, agents, embedded-runner, and test scoped AGENTS.md files were read because the PR touches those areas. (scripts/AGENTS.md:1, efa9a6110b4e)
  • Live PR state: Live GitHub metadata shows the PR is open, not draft, head f0a985f, labeled maintainer, proof sufficient, and mergeable CONFLICTING / merge state DIRTY. (f0a985fa9b48)
  • Accessor contract: The PR-head accessor module documents the storage-neutral session boundary and delegates to file-backed store helpers without flipping storage or adding runtime dual-read behavior. (src/config/sessions/session-accessor.ts:36, f0a985fa9b48)
  • Hot-path follow-up addressed: The embedded attempt path now performs quota-suspension TTL maintenance through loadSessionEntry/updateSessionEntry instead of the earlier unconditional whole-store maintenance call. (src/agents/embedded-agent-runner/run/attempt.ts:821, f0a985fa9b48)
  • Write guard gap: The new legacy writer set checks applySessionStoreEntryPatch, updateSessionStore, and updateSessionStoreEntry, but omits saveSessionStore. (scripts/check-session-accessor-boundary.mjs:26, f0a985fa9b48)

Likely related people:

  • jalehman: Authored this PR and also authored merged/current-main session accessor and transcript identity work in the same migration stack. (role: feature owner; confidence: high; commits: ef47dd610c87, efa9a6110b4e, 5557993f7c30; files: src/config/sessions/session-accessor.ts, scripts/check-session-accessor-boundary.mjs, src/agents/embedded-agent-runner/run/attempt.ts)
  • Alix-007: Recent current-main history touched embedded-runner and transcript/session caching paths adjacent to this session-runtime migration area. (role: recent adjacent contributor; confidence: low; commits: a0b16f37e835; files: src/agents/embedded-agent-runner/run/attempt.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: 🐚 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. 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
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed 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. labels Jun 1, 2026
@jalehman
jalehman marked this pull request as draft June 1, 2026 18:10
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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 force-pushed the clawdbot-6f0/31b-auto-reply-agent-seam branch from 582bdb0 to 522bc6a Compare June 4, 2026 21:25
@jalehman
jalehman changed the base branch from clawdbot-9c3/session-accessor-seam to clawdbot-9c3-ce2/session-accessor-gateway-entry June 4, 2026 21:25
@jalehman
jalehman force-pushed the clawdbot-9c3-ce2/session-accessor-gateway-entry branch 2 times, most recently 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-6f0/31b-auto-reply-agent-seam branch from 522bc6a to 52753f5 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

Copy link
Copy Markdown
Contributor Author

Follow-up before land: this slice still carries a whole-store read on the attempt hot path — loadSessionStore(storePath, { skipCache: true }) + runQuotaSuspensionMaintenance({ storePath }) in src/agents/embedded-agent-runner/run/attempt.ts (~L2947). Per the row-patch decision on #88838 (no whole-store operations on hot paths), this should either move to entry-scoped accessor reads in this PR or be explicitly deferred to the 3.2 caller-plumbing slice with a comment marking it.

@jalehman

Copy link
Copy Markdown
Contributor Author

Posted live Gateway behavior proof in the PR body.

Summary of the new proof:

  • Loaded this branch into the machine's managed OpenClaw Gateway from the live checkout.
  • Rebuilt dist with pnpm build and restarted the LaunchAgent Gateway with pnpm openclaw gateway restart.
  • Confirmed the CLI entry reports OpenClaw 2026.6.2 (f0a985f) and the managed Gateway is running on port 18789.
  • Ran a real Gateway-backed agent turn with openai/gpt-5.5:
    pnpm openclaw agent --agent main --session-key agent:main:pr89124-live-gateway-proof-20260615T2017Z --message 'Reply exactly with PR89124_LIVE_OK and nothing else.' --json --timeout 180
  • Result: run 54cde5c1-d306-4a71-80eb-3d8a8b18d1b6, session 5676b0d9-3548-4b64-aa4a-2df6dcb571bd, output PR89124_LIVE_OK.
  • Verified persisted session row: status: done, modelProvider: openai, model: gpt-5.5, totalTokensFresh: true, transcript file exists.
  • Gateway remained healthy afterward.

This proof used the real local Gateway service, not the earlier isolated in-process harness.

@jalehman

Copy link
Copy Markdown
Contributor Author

Additional live channel proof from the same managed Gateway build (f0a985f):

  • Discord: delivered through the configured Discord channel using pnpm openclaw agent --channel discord --deliver.
    • First stale relay target failed with Discord Missing Access; the configured channel then succeeded.
    • Run 465d5103-b947-4500-ad0c-584a90f8526e, session 6e8d619d-10c7-4bef-b866-4f172ed68ee2, provider/model openai/gpt-5.5, payload PR89124_DISCORD_OK., deliveryStatus sent, succeeded: true.
  • Telegram: delivered through the configured Telegram group topic using pnpm openclaw agent --channel telegram --deliver.
    • Run d575b759-5865-47a4-a5f6-3776ecd99dce, session 6a240460-5e6b-48c0-a52d-207f5fcc1f6d, provider/model openai/gpt-5.5, payload PR89124_TELEGRAM_OK, deliveryStatus sent, succeeded: true.

Both were real live channel adapter deliveries on the LaunchAgent-managed local Gateway, not mocks.

@clawsweeper clawsweeper Bot added 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. 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. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 15, 2026
@jalehman
jalehman force-pushed the clawdbot-6f0/31b-auto-reply-agent-seam branch from 63f9801 to 0ac3386 Compare June 15, 2026 21:14
@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jun 15, 2026
@jalehman

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 15, 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.

Re-review progress:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. 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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant