Skip to content

test(gateway): cover sessions.list limit-before-enrichment paths#74970

Open
anyech wants to merge 1 commit intoopenclaw:mainfrom
anyech:test/sessions-list-fastpath-coverage
Open

test(gateway): cover sessions.list limit-before-enrichment paths#74970
anyech wants to merge 1 commit intoopenclaw:mainfrom
anyech:test/sessions-list-fastpath-coverage

Conversation

@anyech
Copy link
Copy Markdown
Contributor

@anyech anyech commented Apr 30, 2026

Summary

This PR adds regression coverage for the current sessions.list fast path that limits/window-filters safe list requests before expensive row enrichment.

The tests guard the intended slice-1 behavior:

  • safe !spawnedBy && !search calls apply the active window and limit before transcript-backed title/last-message enrichment;
  • global / unknown rows remain excluded by default on the fast path;
  • no rows in the active window returns an empty list without transcript reads;
  • includeDerivedTitles / includeLastMessage toggles do not affect row selection;
  • search + limit remains search-before-limit on the legacy enriched path;
  • spawnedBy remains on the legacy subagent-dependent path.

Context

A local copied-state investigation showed that enriching all candidate sessions before applying activeMinutes/limit can create large avoidable control-plane cost, including transcript reads and repeated subagent-registry reads for rows that are later dropped.

Current main already contains the source-side limit-before-enrichment behavior. This PR is intentionally test-only so that behavior is locked down before any follow-up slices.

Validation

Ran on an isolated checkout only; no live Gateway, live config, installed dist, or live session store was modified or benchmarked.

  • node scripts/run-vitest.mjs run --config test/vitest/vitest.gateway.config.ts src/gateway/session-utils.test.ts src/gateway/session-utils.fs.test.ts — 133 tests passed
  • node scripts/run-vitest.mjs run --config test/vitest/vitest.agents.config.ts src/agents/subagent-registry.persistence.test.ts — 17 tests passed
  • corepack pnpm lint:core — passed
  • corepack pnpm tsgo:core — passed
  • corepack pnpm build — passed
  • git diff --check origin/main..HEAD — passed

Notes

Follow-up implementation work should stay in separate slices:

  • request-scoped subagent registry indexing/cache;
  • transcript fallback caching/deferment;
  • session-store metadata dedupe/capping.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: M labels Apr 30, 2026
@clawsweeper
Copy link
Copy Markdown
Contributor

clawsweeper Bot commented Apr 30, 2026

Codex review: needs real behavior proof before merge.

Summary
The PR adds gateway Vitest coverage for sessions.list active-window and limit selection before transcript enrichment, plus legacy search and spawnedBy ordering boundaries.

Reproducibility: not applicable. this is a test-coverage PR rather than a user-facing bug report. The source path is clear on current main: selection runs before selected-row enrichment, and transcript reads happen inside row enrichment.

Real behavior proof
Needs real behavior proof before merge: The PR body lists only isolated tests/lint/type/build and explicitly says no live Gateway or session store was exercised; the contributor should add terminal output, a screenshot/recording, linked artifact, or redacted logs showing the real sessions.list path, with private IPs, API keys, phone numbers, and non-public endpoints removed, then update the PR body to trigger re-review or ask for @clawsweeper re-review.

Next step before merge
This needs contributor proof plus maintainer CI inspection, not an automated repair PR.

Security
Cleared: The diff is limited to Vitest test code and adds no dependency, workflow, package metadata, secret-handling, or runtime-code change.

Review details

Best possible solution:

Merge the focused regression coverage after acceptable real behavior proof is added and exact-head checks are green, keeping runtime caching or performance slices separate.

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

Not applicable; this is a test-coverage PR rather than a user-facing bug report. The source path is clear on current main: selection runs before selected-row enrichment, and transcript reads happen inside row enrichment.

Is this the best way to solve the issue?

Yes for the diff shape: focused gateway tests are the narrowest maintainable way to lock down the existing ordering without mixing in runtime changes. Merge readiness still depends on real behavior proof and green exact-head checks.

What I checked:

  • Live PR state: The GitHub API shows this PR is open, contributor-authored, non-draft, and changes one file with 227 additions; labels include gateway, size: M, and triage: needs-real-behavior-proof. (0b0123b45351)
  • PR diff scope: The patch is limited to src/gateway/session-utils.test.ts and adds five test cases plus local helpers around safe-list selection, transcript reads, search, and spawnedBy behavior. (src/gateway/session-utils.test.ts:1270, 0b0123b45351)
  • Current main source behavior: Current main calls selectSessionEntries before mapping selected rows through buildGatewaySessionRow, so filtering, sorting, and limiting happen before row enrichment in the synchronous list path. (src/gateway/session-utils.ts:2111, d644798d679e)
  • Transcript enrichment path: Transcript-backed title and last-message fields are read inside row construction only when the selected row requests derived title or last-message data. (src/gateway/session-utils.ts:1762, d644798d679e)
  • Coverage is not already on main: Current main has no matches for the new regression test names added by the PR, so the test-only contribution is not already implemented on main. (src/gateway/session-utils.test.ts, d644798d679e)
  • Proof gap: The PR body reports only isolated checkout tests/lint/type/build validation and explicitly says no live Gateway, live config, installed distribution, or live session store was modified or benchmarked. (0b0123b45351)

Likely related people:

  • steipete: Recent commits bounded sessions.list responses, cached thinking enrichment, and trimmed the session-list hot path in the gateway session utilities. (role: recent area contributor; confidence: high; commits: a224810a7f96, 18bd7b60e4fe, 3aaf30ffa600; files: src/gateway/session-utils.ts, src/gateway/session-utils.test.ts)
  • vincentkoc: Recent merged work reused subagent registry snapshots and bounded transcript/preview hydration in session listing. (role: adjacent hot-path contributor; confidence: high; commits: a1dc8c066347, ec59af33863a, 694598822f19; files: src/gateway/session-utils.ts, src/gateway/session-utils.test.ts, src/gateway/session-utils.subagent.test.ts)
  • amknight: Introduced async transcript I/O and related session-list tests that exercise transcript hydration and event-loop behavior. (role: introduced adjacent behavior; confidence: high; commits: 6f819280a302, 54a81e00807b; files: src/gateway/session-utils.ts, src/gateway/session-utils.test.ts)
  • Peetiegonzalez: Added the lightweight sessions.list row path that reduced row-enrichment cost in the same implementation area. (role: introduced lightweight list row path; confidence: medium; commits: 7fe4ba013ff0; files: src/gateway/session-utils.ts)

Remaining risk / open question:

  • Exact-head Node shard checks are currently failing; the CI root cause should be inspected before merge.

Codex review notes: model gpt-5.5, reasoning high; reviewed against d644798d679e.

@anyech anyech force-pushed the test/sessions-list-fastpath-coverage branch 3 times, most recently from 04483b2 to b5433bb Compare May 4, 2026 06:53
Add regression coverage for sessions.list safe-path selection, transcript
avoidance, and legacy search/spawnedBy boundaries. These tests guard the
existing main-branch implementation that limits before row enrichment on
safe list paths.
@anyech anyech force-pushed the test/sessions-list-fastpath-coverage branch from b5433bb to 0b0123b Compare May 10, 2026 02:47
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime size: M triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant