Skip to content

refactor(sessions): consolidate transcript and state helpers - #119435

Merged
steipete merged 1 commit into
mainfrom
codex/loc-0804-sessions-luem8u
Aug 5, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/loc-0804-sessions-luem8u

Conversation

@steipete

@steipete steipete commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Session, transcript, and agent-state owners repeated equivalent record/string coercion, provider wrappers, transcript event projections, and export allowlists. This is part of a maintainer-requested project-wide production LOC reduction campaign.

Why This Change Was Made

Reuse canonical normalization and transcript owners while preserving SQLite migrations, public/private transcript boundaries, metadata-first export ordering, and session recovery.

User Impact

Session persistence, transcript exports, lifecycle events, and database schema remain unchanged; removes 106 production lines.

Evidence

Exact-head transcript event and privacy proof

The actual committed transcript-event owner, both canonical production normalization modules, and the real production global singleton owner were source-compiled and executed in an isolated Node VM. Only synthetic identities and paths were used; no gateway, database, live user state, or mocked emitter logic was involved.

{
  "commit":"dbcd06badb8ebbbf95056298a30eca721b1d4d38",
  "source":"src/sessions/transcript-events.ts",
  "verifiedGitBlob":"cf18c68669c06cbe13507d85611e21719d980576",
  "publicEvent":{"target":{"agentId":"fixture-agent","sessionId":"fixture-session","sessionKey":"agent:fixture-agent:main"},"sessionKey":"agent:fixture-agent:main","agentId":"fixture-agent","sessionId":"fixture-session","message":{"role":"assistant","content":"[synthetic redacted fixture]"},"messageId":"fixture-message","messageSeq":7},
  "internalEvent":{"sessionFile":"/redacted/state/fixture-session.jsonl","target":{"agentId":"fixture-agent","sessionId":"fixture-session","sessionKey":"agent:fixture-agent:main","storePath":"/redacted/state/openclaw.sqlite"},"sessionKey":"agent:fixture-agent:main","agentId":"fixture-agent","sessionId":"fixture-session","lifecycleRevision":"fixture-revision","message":{"role":"assistant","content":"[synthetic redacted fixture]"},"messageId":"fixture-message","messageSeq":7},
  "archiveOnlyEvent":{"publicDeliveries":0,"internalEvent":{"sessionFile":"/redacted/state/archive-only.jsonl"},"invalidSequenceDropped":true},
  "listenerFailureIsolation":{"publicListenersThrown":1,"publicEventsDelivered":1,"internalListenersThrown":2,"internalEventsDelivered":2},
  "assertions":"PASS: exact commit/blob; canonical normalization; public redaction; owner-only archive delivery; listener failure isolation"
}

Public listeners received no sessionFile, target.storePath, or lifecycleRevision; internal owner listeners retained all three. Throwing listeners did not prevent subsequent listeners from receiving events. The requested transcript-event proof is therefore supplied. A fresh bot re-review is intentionally skipped because the reviewed Git head did not change; root policy explicitly requires no re-review round trip when rank-up moves are addressed without modifying the reviewed head.

@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Aug 5, 2026
@steipete
steipete marked this pull request as ready for review August 5, 2026 02:50
@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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Aug 5, 2026
@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 4, 2026, 11:22 PM ET / August 5, 2026, 03:22 UTC.

ClawSweeper review

What this changes

This PR replaces duplicated session, transcript, migration, and export normalization helpers with canonical shared helpers while preserving existing behavior.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open: current main does not contain this behavior-preserving consolidation, and the exact-head proof addresses the prior real-behavior request. No blocking correctness or security finding was identified; the protected maintainer label leaves landing to explicit human review.

Priority: P3
Reviewed head: dbcd06badb8ebbbf95056298a30eca721b1d4d38
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused net-negative refactor with exact-head runtime evidence and no supported correctness finding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR body supplies exact-head terminal output from the compiled transcript-event owner using the production normalizers and singleton, showing redaction, internal delivery, invalid-sequence handling, and listener isolation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body supplies exact-head terminal output from the compiled transcript-event owner using the production normalizers and singleton, showing redaction, internal delivery, invalid-sequence handling, and listener isolation.
Evidence reviewed 5 items Current main does not already contain the refactor: Current main still calls the transcript normalizer with the now-removed identity-only option, while the PR removes that redundant wrapper; the central cleanup remains necessary.
Canonical helper contracts match removed helpers: The shared helpers trim optional strings, reject arrays as records, and retain the same positive-integer and non-negative-finite predicates used by the deleted local helpers.
Sensitive transcript boundary remains intact: The PR head normalizes events, projects public events without sessionFile, storePath, or lifecycleRevision, and retains those fields for internal listeners; existing focused tests cover archive-only delivery, identity updates, privacy, invalid sequence handling, and listener isolation.
Findings None None.
Security None None.

How this fits together

Session and transcript code turns incoming turns and persisted session records into transcript events, SQLite projections, and export artifacts. This refactor centralizes their input normalization before those downstream persistence and delivery paths run.

flowchart TD
  A[Session and transcript inputs] --> B[Shared normalization helpers]
  B --> C[Transcript event delivery]
  B --> D[SQLite session migrations]
  B --> E[User-turn media records]
  C --> F[Public and internal listeners]
  D --> G[Session state]
  E --> H[Transcript exports]
Loading

Decision needed

Question Recommendation
Should this maintainer-requested production-LOC refactor be approved once its exact head has current merge and CI confirmation? Approve after refresh: Accept the behavior-neutral consolidation after the normal exact-head mergeability and required-check refresh.

Why: The protected maintainer label requires explicit human handling even though the code review and supplied proof show no blocking defect.

Before merge

  • Resolve merge risk (P1) - The branch is 11 commits behind current main; touched paths and shared helper dependencies are unchanged, but mergeability and required checks should be refreshed on the exact head before landing.
Agent review details

Security

None.

PR surface

Source -106. Total -106 across 12 files.

View PR surface stats
Area Files Added Removed Net
Source 12 117 223 -106
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 117 223 -106

Review metrics

Metric Value Why it matters
Production versus test LOC production -106, tests 0 All 12 changed files are production code, so the net reduction directly advances the stated consolidation without expanding test surface.

Stored data model

Persistent data-model change detected: serialized state: src/sessions/conversation-turns.ts, serialized state: src/sessions/session-chat-type.ts, serialized state: src/sessions/transcript-events.ts, serialized state: src/sessions/user-turn-transcript.media-normalize.ts, serialized state: src/sessions/user-turn-transcript.ts, serialized state: src/state/openclaw-agent-db-session-migrations.ts, and 10 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the focused canonical-helper consolidation and land it after the maintainer approves the exact-head merge and CI state.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the focused canonical-helper consolidation and land it after the maintainer approves the exact-head merge and CI state.

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

Not applicable: this is a behavior-preserving refactor, and the supplied exact-head runtime output exercises the sensitive transcript-event path rather than a reported failure.

Is this the best way to solve the issue?

Yes: replacing equivalent local coercion and record checks with the existing canonical helpers is the narrowest maintainable solution, and source comparison found no changed predicate or owner boundary.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies exact-head terminal output from the compiled transcript-event owner using the production normalizers and singleton, showing redaction, internal delivery, invalid-sequence handling, and listener isolation.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body supplies exact-head terminal output from the compiled transcript-event owner using the production normalizers and singleton, showing redaction, internal delivery, invalid-sequence handling, and listener isolation.
  • remove rating: 🧂 unranked krab: 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:

  • P3: This is a behavior-neutral internal cleanup with no demonstrated user-facing regression or urgent operational impact.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body supplies exact-head terminal output from the compiled transcript-event owner using the production normalizers and singleton, showing redaction, internal delivery, invalid-sequence handling, and listener isolation.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies exact-head terminal output from the compiled transcript-event owner using the production normalizers and singleton, showing redaction, internal delivery, invalid-sequence handling, and listener isolation.

Evidence

What I checked:

  • Current main does not already contain the refactor: Current main still calls the transcript normalizer with the now-removed identity-only option, while the PR removes that redundant wrapper; the central cleanup remains necessary. (src/sessions/transcript-events.ts:71, a8caab5c3d3c)
  • Canonical helper contracts match removed helpers: The shared helpers trim optional strings, reject arrays as records, and retain the same positive-integer and non-negative-finite predicates used by the deleted local helpers. (packages/normalization-core/src/string-coerce.ts:7, a8caab5c3d3c)
  • Sensitive transcript boundary remains intact: The PR head normalizes events, projects public events without sessionFile, storePath, or lifecycleRevision, and retains those fields for internal listeners; existing focused tests cover archive-only delivery, identity updates, privacy, invalid sequence handling, and listener isolation. (src/sessions/transcript-events.ts:70, dbcd06badb8e)
  • Main drift does not overlap the patch: Current main is 11 commits beyond the PR base, but neither the 12 touched files nor the shared normalization and transcript-artifact dependencies changed since that base. (src/transcripts/store.ts:608, a8caab5c3d3c)
  • Area provenance: Visible history ties the current transcript/session area to a recent refactor by Vincent Koc, while Peter Steinberger has prior merged session and transcript refactors in the same paths. (src/sessions/transcript-events.ts:71, 6293b54250fc)

Likely related people:

  • steipete: Merged history includes durable session/transcript refactors in the affected files, beyond authorship of this PR. (role: long-running session and transcript refactor contributor; confidence: medium; commits: 4273ca9dbd9b, 129f86bbf5e6, c5a2220d3771; files: src/sessions/transcript-events.ts, src/state/openclaw-agent-db-session-provenance.ts, src/transcripts/store.ts)
  • Vincent Koc: Current visible blame on the transcript event path points to the recent plugin-registry refactor commit; deeper history is partially unavailable locally. (role: recent area contributor; confidence: low; commits: 6293b54250fc; files: src/sessions/transcript-events.ts, src/state/openclaw-agent-db-session-migrations.ts, src/transcripts/store.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Refresh the exact head's normal mergeability and required-check state before landing.

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 (1 earlier review cycle)
  • reviewed 2026-08-05T03:03:59.095Z sha dbcd06b :: needs real behavior proof before merge. :: none

@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 Aug 5, 2026
@steipete
steipete merged commit 39bbd8a into main Aug 5, 2026
199 of 212 checks passed
@steipete
steipete deleted the codex/loc-0804-sessions-luem8u branch August 5, 2026 03:45
@steipete

steipete commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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