Skip to content

refactor(sessions): consolidate entry state - #115299

Merged
steipete merged 5 commits into
mainfrom
steipete/session-entry-diet
Jul 28, 2026
Merged

steipete merged 5 commits into
mainfrom
steipete/session-entry-diet

Conversation

@steipete

@steipete steipete commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Session entries carried several clusters of parallel nullable fields for pending final delivery, fallback notices, and memory flush state. Those fields allowed invalid combinations and forced recovery, reset, status, and delivery consumers to reconstruct state independently. Gateway session rows also retained a duplicate kind classifier.

Why This Change Was Made

This maintainer-requested cleanup replaces the three field clusters with closed nested states and normalizes legacy persisted fields once at the session-store read boundary. It also routes Gateway row classification through the shared session-kind owner while preserving the older four-value Gateway wire contract.

Two investigated goals were intentionally skipped:

  • usageFamilyKey / usageFamilySessionIds remain because supported file-backed and legacy session stores cannot recover historical JSONL lineage cheaply from the SQLite session_windows chain.
  • The gateway-protocol export sweep removed nothing because fresh Knip found only eight candidates, all reachable from published package entry points and therefore client-consumable.

ClawSweeper status: the latest existing comment is a stale review-started placeholder and contains no Rank-up moves:. Dispatch 30384857576 succeeded, but exact-review runs 30384823618, 30385268156, 30385738698, 30386188180, and 30386646553 were cancelled before execution; per maintainer ruling, there are no moves to apply and landing proceeds with this publisher wedge recorded.

No schema, config, protocol-version, or changelog changes are included. The parked steipete/session-read-pushdown overlap files were not touched.

User Impact

There is no new user-facing capability. Session recovery and accounting retain their existing behavior with fewer invalid internal states, and legacy persisted session metadata is normalized before consumers observe it.

AI-assisted implementation; the complete diff was reviewed with the repository autoreview workflow.

Evidence

Goal outcomes:

  1. SessionEntry clusters: done. Pending final delivery is replayable | transport-only; fallback notice is one active record; memory flush is succeeded | failed.
  2. Duplicate kind classifiers: done. Gateway uses the shared classifier and explicitly folds cron/spawn-child to direct for its established wire shape.
  3. Usage-family retirement: skipped for file-backed/legacy lineage correctness.
  4. Gateway-protocol dead exports: skipped because all eight fresh candidates are published surfaces.

LOC governor:

Scope Added Deleted Net
Non-test 344 345 -1
Tests 678 647 +31
Total 1022 992 +30

Validation:

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime commands Command implementations agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Jul 28, 2026
@steipete steipete self-assigned this Jul 28, 2026
@steipete
steipete marked this pull request as ready for review July 28, 2026 16:51
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@steipete
steipete merged commit 8ee1d04 into main Jul 28, 2026
131 checks passed
@steipete
steipete deleted the steipete/session-entry-diet branch July 28, 2026 18:31
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit to christian-lallo/openclaw that referenced this pull request Jul 28, 2026
* origin/main: (61 commits)
  perf(ui): debounce event-driven session list refreshes and right-size child paging (openclaw#115374)
  feat(talk): support GPT-Live realtime voice over ChatGPT OAuth (openclaw#115226)
  feat(system-agent): guide gateway configuration in Ask OpenClaw (openclaw#115363)
  fix(agents): make overflow recovery append-only via branch-and-reappend (openclaw#115271) (openclaw#115310)
  fix(macos): bound websocket ping so a dropped pong cannot orphan its continuation (openclaw#115362)
  fix(codex): isolate native hook relay startup (openclaw#115078)
  fix(ci): stop reviving superseded pull request workflows (openclaw#115378)
  feat(openshell): add workspace selection (openclaw#114952)
  fix(skills): persist workshop apply reason; correct Skill Workshop docs (openclaw#114471)
  fix: agent stops replying when a session transcript has no header row (openclaw#115080)
  perf(usage): stale-while-revalidate caches for usage.status and sessions.usage (openclaw#115369)
  fix(discord): reject invalid UTF-8 probe responses (openclaw#111734)
  feat(gateway): add memory.search operator method (openclaw#115346)
  fix(android): keep welcome action reachable with large text (openclaw#111747)
  fix(gateway): validate doctor memory agent ids (openclaw#115365)
  refactor: harden shell completion and shard Control UI E2E (openclaw#115332)
  fix(ui): anchor the thread branches menu to its trigger button (openclaw#115352)
  perf(sessions): incremental snapshot revalidation and shallow list projections (openclaw#115359)
  refactor(sessions): consolidate entry state (openclaw#115299)
  feat(ui): swap three plain Lobsterdex palettes for balloon, ascii, and portal (openclaw#115308)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 29, 2026
* refactor(sessions): consolidate entry state

* refactor(gateway): unify session kind classification

* refactor(sessions): keep entry state types private

* test(sessions): drop retired pending delivery case

* fix(sessions): clear stale transport-only delivery
steipete added a commit that referenced this pull request Aug 15, 2026
…he gateway

The sessions.changed merge deleted null-tombstoned fields from a hand-kept
eleven-field list while the gateway's tombstone policy
(session-event-payload.ts) had grown past it: toolOverrides, observerDigest,
controlOwnerSessionKey, restartRecoveryStatus, and goal leaked literal null
into rows typed optional-not-null, and every new tombstoned field would
silently repeat the drift. One loop over the event's null-valued keys now
owns the rule; updatedAt/activeLeafEntryId (the schema's only nullable row
fields) keep their explicit handling. Net −24 lines.

Riders in the same owner neighborhood:
- compareSessionRowsByUpdatedAt gains the gateway's ascending-key tie-break
  (session-list-order.ts: "Stable key ties keep offset paging deterministic")
  so tied rows — including all updatedAt:null rows — stop visibly swapping
  when the canonical refresh replaces an event-driven reconcile.
- Deleted the unreachable kind === "cron" wire guards (gateway folds cron to
  direct before projection, #115299; both sites needed an `as string` cast
  because the protocol type has no such member).
- The stale-active-snapshot path returns the original result identity when no
  defaults were passed, so the caller's result === state.result publish gate
  skips a spurious sidebar re-render on every stale event.
steipete added a commit that referenced this pull request Aug 15, 2026
…he gateway (#124104)

* fix(ui): reconcile every null tombstone and align session sort with the gateway

The sessions.changed merge deleted null-tombstoned fields from a hand-kept
eleven-field list while the gateway's tombstone policy
(session-event-payload.ts) had grown past it: toolOverrides, observerDigest,
controlOwnerSessionKey, restartRecoveryStatus, and goal leaked literal null
into rows typed optional-not-null, and every new tombstoned field would
silently repeat the drift. One loop over the event's null-valued keys now
owns the rule; updatedAt/activeLeafEntryId (the schema's only nullable row
fields) keep their explicit handling. Net −24 lines.

Riders in the same owner neighborhood:
- compareSessionRowsByUpdatedAt gains the gateway's ascending-key tie-break
  (session-list-order.ts: "Stable key ties keep offset paging deterministic")
  so tied rows — including all updatedAt:null rows — stop visibly swapping
  when the canonical refresh replaces an event-driven reconcile.
- Deleted the unreachable kind === "cron" wire guards (gateway folds cron to
  direct before projection, #115299; both sites needed an `as string` cast
  because the protocol type has no such member).
- The stale-active-snapshot path returns the original result identity when no
  defaults were passed, so the caller's result === state.result publish gate
  skips a spurious sidebar re-render on every stale event.

* test(ui): pin the ascending-key tie for equal-updatedAt sidebar rows

* test(ui): tolerate CI renderer jitter in the typing-shift picker guard

The 2px y-tolerance flaked at 2.41px on CI renderers; the #122809
regression this guards against shifts by a full indicator row (~20px).
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 16, 2026
…he gateway (openclaw#124104)

* fix(ui): reconcile every null tombstone and align session sort with the gateway

The sessions.changed merge deleted null-tombstoned fields from a hand-kept
eleven-field list while the gateway's tombstone policy
(session-event-payload.ts) had grown past it: toolOverrides, observerDigest,
controlOwnerSessionKey, restartRecoveryStatus, and goal leaked literal null
into rows typed optional-not-null, and every new tombstoned field would
silently repeat the drift. One loop over the event's null-valued keys now
owns the rule; updatedAt/activeLeafEntryId (the schema's only nullable row
fields) keep their explicit handling. Net −24 lines.

Riders in the same owner neighborhood:
- compareSessionRowsByUpdatedAt gains the gateway's ascending-key tie-break
  (session-list-order.ts: "Stable key ties keep offset paging deterministic")
  so tied rows — including all updatedAt:null rows — stop visibly swapping
  when the canonical refresh replaces an event-driven reconcile.
- Deleted the unreachable kind === "cron" wire guards (gateway folds cron to
  direct before projection, openclaw#115299; both sites needed an `as string` cast
  because the protocol type has no such member).
- The stale-active-snapshot path returns the original result identity when no
  defaults were passed, so the caller's result === state.result publish gate
  skips a spurious sidebar re-render on every stale event.

* test(ui): pin the ascending-key tie for equal-updatedAt sidebar rows

* test(ui): tolerate CI renderer jitter in the typing-shift picker guard

The 2px y-tolerance flaked at 2.41px on CI renderers; the openclaw#122809
regression this guards against shifts by a full indicator row (~20px).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations gateway Gateway runtime maintainer Maintainer-authored PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant