Skip to content

refactor: simplify Gateway session-name precedence - #147984

Merged
steipete merged 3 commits into
mainfrom
codex/perf-sep13-display-name
Sep 18, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/perf-sep13-display-name

Conversation

@steipete

@steipete steipete commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Gateway session-name selection computes fallback metadata even when an explicit label or human group title already determines the name.

User Impact

No user-visible behavior change. Name precedence, raw label fields, empty stored/generated names, iMessage identity suppression, and dashboard behavior remain unchanged. No configuration, storage, protocol, or migration changes.

Why This Change Was Made

Return at the existing label/title decisions, defer channel/origin/key parsing until needed, and remove the now-redundant title conditions. The existing display owner stays responsible; no cache or new abstraction is added. Production code shrinks by nine lines. The separate active-run projection is untouched.

Current validation (September 18)

Integrated current main 7bc487d39dc9e059bb9b19ea08152883022f83fe through an ordinary merge, preserving the existing PR ancestry. The five-case precedence test now uses a typed tuple table with the same case names, inputs, expected values, and raw label/autoLabel assertions. Production remains nine lines smaller; tests are three lines smaller than the integrated main baseline. No cap, baseline, or assertion was weakened.

  • Full current session-utils.test.ts: 265 passed, no skips; 64.32 seconds wall time. This is correctness-suite duration, not a before/after performance result.
  • Fresh standard Codex P2 review: scoped clean, no actionable findings.
  • Formatting and the canonical line-cap ratchet passed for the two-file delta.
  • All maintained changed checks passed locally, including full core and core-test typing, type-aware lint, dead-export/import-cycle checks, and the remaining selected guards. Fresh exact-head hosted CI and native landing gates remain required; no green-CI or merge claim yet.

The production simplification is unchanged. Main90f47f2e7a0076308f387a33e1faec85a11408ac was subsequently integrated to include the separately landed messaging type-graph repair (#151564). The full265-case row suite passed again with the current row-title preparation owner. Earlier performance measurements below remain historical and mixed; no new timing benefit is claimed for this refresh.

Historical evidence

  • Ordinary Codex P2 review: no actionable findings on the exact patch.
  • Full session-utils.test.ts: 266 passed, no skips; the existing precedence case now covers padded/blank explicit labels and empty stored/generated names without duplicated setup.
  • Four selected real sessions-read handler cases passed: presentation facts, short-ID ownership, describe ownership, and displayed-field search. Nineteen unrelated cases were outside the selected pattern. This is handler-boundary proof, not a live WebSocket Gateway test.
  • Formatting and the maintained changed-test selector's gateway-root type graph passed. No full build or broad local graph claim; hosted CI remains separate.
  • Actual exported row/list owners: untimed preflight plus fixed B1/C1/C2/B2 processes, 12 cells per process and five observations per cell, all 240 complete. Complete decoded output parity and input immutability passed. Independent retained-data audit confirmed values, property order, object-sharing topology, and JSON projections. V8 bytes differed for some equivalent outputs; identical serialization bytes are not claimed. The failed extra byte-hash assumption was retained and did not alter or rerun the oracle.

The measurements are small and mixed and do not establish a broad speedup. At 1,000 rows, explicit-label row/list medians were about 0.9–1.6% lower in both orders. Other rows include regressions and sign changes; none were excluded.

Complete fixed-run wall medians and limitations

Milliseconds per complete roster pass; negative delta means candidate lower. Each median uses five within-process observations, with only two independent processes per source.

Owner / rows / cohort B1 C1 C2 B2 C1 vs B1 C2 vs B2
row-100rows-explicit-labels 58.323 56.354 62.400 56.438 -3.38% +10.56%
list-100rows-explicit-labels 43.206 43.286 44.952 43.833 +0.18% +2.55%
row-100rows-group-titles 47.520 46.674 47.471 47.733 -1.78% -0.55%
list-100rows-group-titles 39.743 40.030 40.187 39.881 +0.72% +0.77%
row-100rows-fallback-controls 14.528 14.462 14.328 13.639 -0.46% +5.05%
list-100rows-fallback-controls 6.066 6.325 6.276 6.210 +4.28% +1.07%
row-1000rows-explicit-labels 456.842 451.246 456.522 460.574 -1.22% -0.88%
list-1000rows-explicit-labels 382.178 378.297 375.879 382.085 -1.02% -1.62%
row-1000rows-group-titles 445.473 453.526 446.496 450.149 +1.81% -0.81%
list-1000rows-group-titles 372.600 379.291 370.382 374.973 +1.80% -1.22%
row-1000rows-fallback-controls 131.909 134.696 132.981 134.752 +2.11% -1.31%
list-1000rows-fallback-controls 49.898 51.085 50.399 51.028 +2.38% -1.23%

Node 26.8.2, fixed synthetic in-memory rosters, empty plugin/run/account state and model catalog, frozen wall clock, no transcript hydration. Row context/child index preparation is outside timing; list preparation is real per call. Controls cover explicit labels, human group titles, opaque/compact iMessage identities, an untitled internal dashboard, and empty stored/generated names. The dashboard fixture contains no sender-origin data and does not independently prove sender-identity suppression; existing tests cover that contract.

Other product jobs were held, but native/public I/O could continue. This was not an idle machine or isolated host. Cell CPU samples and whole-process resource receipts are retained; process metrics include imports, initialization, untimed parity, and cleanup, and do not isolate the resolver. There was no calibration, threshold selection, retry, outlier rejection, or added scale. No model, network, WebSocket, or full Gateway throughput claim.

All registry/database owners, processes, and groups closed. Raw samples, partial-result handling, inventories, source/runtime bindings, and used admissions are retained. Baseline: 0a8e1d5b91806f1503f3ef46bc2165cc2ceaa044; exact patch SHA-256: 213e9d9b4f9f2c62837f515d9ecdfd68770468d336a6acf7ea5f8f4078fe9e81; independent data-audit SHA-256: c5ff2edbe825b2022e817bbd01bd9c10960b30b0cb7e266f46ca5dec0965df10.

CI history: the original head failed the Control UI startup gzip gate. The unchanged two-file patch has now been replayed onto main 43d413bd39385ab04e1059c39aadafa4f30445cc, which contains the separate startup-code reduction in #147973 and the upstream budget-policy refresh in #148010. This PR changes neither policy nor UI source; neither upstream change is counted as its performance gain. Original failing logs and measurements remain preserved. Fresh exact-head CI is required before landing; no benchmark retiming or local dependency reconciliation was performed for this patch-identical replay.

Closes #147982

Subsequent CI refresh: run 34829946379 on 63aab1365f3f222c05b5553187c032ae66140097 failed the Docker ClawHub fixture expectation (355 cases passed, one failed in that job). That expectation was repaired separately on main by #148129 (abbdd5287afc59899721285bca79fdfd8e6d289d). The unchanged two-file patch is now replayed onto ac3bd358a87ae876fbbc23abbe8a0a7663ece325 as 9e67a06120788c45f184711872fd158070322ccf. Full touched beforeimages and the patch remain identical. Earlier UI and fixture failures stay recorded; this refresh is not a new benchmark or a green-CI claim. Fresh exact-head CI is required before landing.

@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review September 14, 2026 06:06
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Sep 14, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 Sep 14, 2026
@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 18, 2026, 4:12 AM ET / 08:12 UTC (Revision 6).

ClawSweeper review

What this changes

Simplify Gateway conversation-name selection with early returns and extend existing row tests for padded labels, blank labels, and empty names.

Merge readiness

✅ Ready for maintainer review

No actionable defect found. The cleanup remains absent from current main, preserves existing naming behavior, and belongs with the active maintainer-authored implementation.

Priority: P3
Reviewed head: ae50a5d38caf1e9f2d8552aa2db33d2147fa8f28

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, behavior-preserving simplification with useful boundary assertions and no actionable findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER author status exempts this internal refactor from contributor live-proof requirements. Reported row/list parity exercises the changed naming owner on synthetic inputs; it is not live Gateway proof. Inspected media belongs to an unrelated UI PR.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER author status exempts this internal refactor from contributor live-proof requirements. Reported row/list parity exercises the changed naming owner on synthetic inputs; it is not live Gateway proof. Inspected media belongs to an unrelated UI PR.
Evidence reviewed 8 items Introduced patch and review continuity: The pinned base-to-head diff changes only name selection and its existing precedence test. Comparing the previous reviewed head with this head produced no changes in either reviewed file; the supplied prior review contains no outstanding findings.
Current main still has the original evaluation path: Fetched main calculates lower-priority metadata before applying the final precedence chain. The PR's early-return cleanup is therefore still distinct. The provided merged related PRs repair unrelated UI or CI behavior, not this request.
Helper contracts support equivalent early returns: The group-title helper reads only subject, topicName, groupChannel, and space, returning a nonempty string or undefined. Passing the session entry preserves those inputs. Delivery helpers only read canonical metadata; deferring them removes no required side effect.
Findings None None.
Security None None.

How this fits together

The Gateway combines stored session metadata and channel information into conversation names. Session listings, searches, and session resolution consume those names.

flowchart TD
  A[Session key and metadata] --> B{Explicit rename?}
  B -->|Yes| F[Conversation name]
  B -->|No| C{Human group title?}
  C -->|Yes| F
  C -->|No| D[Stored or generated name]
  D -->|Absent| E[Filtered origin fallback]
  D -->|Present| F
  E --> F
  F --> G[Session lists and resolution]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -9, Tests -3. Total -12 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 29 38 -9
Tests 1 18 21 -3
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 47 59 -12

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #147982
Summary: This PR implements the linked open cleanup request; the related CI and UI repairs address separate problems.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep naming precedence in the existing display owner and skip lower-priority work once the result is determined.

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

Not applicable: the linked request explicitly describes internal cleanup rather than a title-rendering bug; current source confirms the unnecessary fallback computation.

Is this the best way to solve the issue?

Yes. Early returns preserve the existing nullish precedence and identity filters without adding state, abstractions, or another naming owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against c8cfd5218888.

Labels

Label justifications:

  • P3: This is a bounded internal cleanup with preserved behavior and no claimed user-facing defect.
  • 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 supplied MEMBER author status exempts this internal refactor from contributor live-proof requirements. Reported row/list parity exercises the changed naming owner on synthetic inputs; it is not live Gateway proof. Inspected media belongs to an unrelated UI PR.

Evidence

What I checked:

  • Introduced patch and review continuity: The pinned base-to-head diff changes only name selection and its existing precedence test. Comparing the previous reviewed head with this head produced no changes in either reviewed file; the supplied prior review contains no outstanding findings. (src/gateway/session-utils-display.ts:27, ae50a5d38caf)
  • Current main still has the original evaluation path: Fetched main calculates lower-priority metadata before applying the final precedence chain. The PR's early-return cleanup is therefore still distinct. The provided merged related PRs repair unrelated UI or CI behavior, not this request. (src/gateway/session-utils-display.ts:27, c8cfd5218888)
  • Helper contracts support equivalent early returns: The group-title helper reads only subject, topicName, groupChannel, and space, returning a nonempty string or undefined. Passing the session entry preserves those inputs. Delivery helpers only read canonical metadata; deferring them removes no required side effect. (src/config/sessions/group.ts:89, ae50a5d38caf)
  • Observable precedence coverage: The five-case table checks resulting row names and preserves raw label/autoLabel assertions. Adjacent coverage exercises readable aliases, opaque iMessage identities, dashboard behavior, human group titles, explicit group renames, and compact fallbacks. (src/gateway/session-utils.test.ts:2908, ae50a5d38caf)
  • Shared production consumers: Row preparation, metadata search, and session resolution use the same display-name owner. This diff introduces no second naming policy, persistence writer, authorization decision, or Codex dependency. (src/gateway/session-utils-row.ts:132, ae50a5d38caf)
  • Captured validation and linked request: The supplied PR body reports 265 passing current row tests and historical row/list-owner output parity using synthetic rosters. It explicitly disclaims a broad speedup and live WebSocket proof. The open same-author request Simplify Gateway session-name precedence #147982 describes this exact cleanup and is linked for closure by this PR. (ae50a5d38caf)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Omar Shahine: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (5 earlier review cycles)
  • reviewed 2026-09-14T06:18:22.115Z sha 914acc6 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-14T07:11:05.405Z sha 914acc6 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-14T15:47:23.393Z sha 63aab13 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-18T03:31:56.985Z sha 9e67a06 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-18T07:11:07.697Z sha d22449a :: needs maintainer review before merge. :: none

Return when explicit labels or human group titles determine the name.
Defer fallback parsing while preserving nullish precedence and identity
suppression. Extend the existing row precedence case for blank labels
and empty stored or generated names.

Full row tests, selected sessions-read handlers, and the matching Gateway
type graph passed. Fixed row/list measurements were small and mixed;
no broad speedup is claimed.
@steipete
steipete merged commit 3955889 into main Sep 18, 2026
211 checks passed
@steipete
steipete deleted the codex/perf-sep13-display-name branch September 18, 2026 08:49
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 18, 2026
Punchcard-Session: ember-river-harbor-t4

* commit 'fdbb2455ac991202051904501438f690d22a0701': (21 commits)
  fix(qa): restore Telegram skill integration checks (#151632)
  test(e2e): follow published plugin convergence restarts (#151607)
  perf(tasks): skip unnecessary maintenance record copies (#151578)
  refactor: simplify Gateway session-name precedence (#147984)
  fix(ui): keep suggested task launches in the background (#151611)
  fix(agents): preserve subagent progress across repeated restarts (#151450)
  fix(diagnostics): scale memory growth pressure to the heap limit (#151355)
  fix(ui): release reply previews when connections retire (#145907)
  fix(ui): disable skeleton shimmers when motion is reduced (#151314)
  fix(gateway): reduce worker overhead with large session stores (#149700)
  improve: defer unused work during Gateway startup (#151547)
  improve: reduce transcript freshness-check overhead (#151606)
  fix(ui): keep Home from appearing twice in the sidebar (#151401)
  improve(gateway): reduce allocations during large session refreshes (#151565)
  improve: reduce temporary allocations for long provider requests (#151603)
  fix: keep Gateway responsive and preserve completions during SQLite contention (#151594)
  fix(models): renew successful empty provider catalogs (#151580)
  fix: reveal preserved chat branches after rewind and resend (#151598)
  perf(outbound): skip inert plain-text preparation scans (#149829)
  improve(ui): make toast feedback compact and recovery readable (#151575)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 19, 2026
Return when explicit labels or human group titles determine the name.
Defer fallback parsing while preserving nullish precedence and identity
suppression. Extend the existing row precedence case for blank labels
and empty stored or generated names.

Full row tests, selected sessions-read handlers, and the matching Gateway
type graph passed. Fixed row/list measurements were small and mixed;
no broad speedup is claimed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

Simplify Gateway session-name precedence

1 participant