Skip to content

improve: reduce unnecessary session-history imports - #154740

Merged
steipete merged 1 commit into
mainfrom
codex/lightweight-session-delivery-readers
Sep 21, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/lightweight-session-delivery-readers

Conversation

@steipete

@steipete steipete commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Closes #154738

What Problem This Solves

Session-history readers load route-normalization dependencies merely to read already persisted delivery fields.

User Impact

No user-visible behavior change is intended. This reduces unnecessary imports in the session-history worker while preserving delivery behavior and the existing public SDK exports. No migration is required.

Compatibility review covers the complete 82-file diff: no configuration keys, defaults, SQLite schemas, migrations, persisted fields, serialization, retention, or database paths change. The four reader function bodies and public SDK signatures are preserved. Upgrading or rolling back requires no data conversion. ClawSweeper's compatibility placeholders were triggered by an incomplete file inventory (unknown-truncated-pull-files), not an identified configuration or data-model change.

Why This Change Was Made

The four delivery readers only select fields from the canonical session record. Moving them into a module with type-only dependencies lets callers read those fields without importing normalization runtime. Normalization keeps its existing owner. The restart-sentinel test fixture moves into its existing support module to keep the changed file within the repository's line limit; its defaults and assertions are preserved.

Evidence

Historical proof for the reviewed candidate based on 591f7bad7e333a6a879e38cfffab7bbc17055800:

  • Build and selected type, format, lint, source/import, and database guards passed. All 234 tests across six focused files passed; independent review reported no actionable findings.
  • The compiled Codex session-history worker's reachable static import graph fell from 291 files / 3,300,129 bytes to 277 files / 3,112,317 bytes: 14 fewer files and 5.69% fewer bytes. The measured memory-index, memory-search, document-extract, and Codex catalog graphs were unchanged.
  • Matched Matrix import profiling on Node 26.8.2 reused the exact retained builds, with six fresh-process runs per arm in ABBA order repeated three times. Median peak RSS was 135.56 MiB baseline versus 135.53 MiB candidate, within observed run variation. Source and dependency identities remained unchanged. This does not establish a latency or RSS improvement.

Candidate commit 309866379668fe5abf0ac13a5cce5740de24f8c1 integrates onto 4d9c6d9aefa5f3764f109bf8965f6c21a36fa9a3 without conflicts: 80 of 82 files are byte-identical to the reviewed candidate. The other two preserve upstream asynchronous delivery-queue lookup and matching test mocks. No unmigrated reader imports were found; whitespace and independent patch-application checks passed. All 82 source hashes match the integrated packet after committing.

Current-head GitHub CI passed for 309866379668fe5abf0ac13a5cce5740de24f8c1, and enforced dependency/security/CI gates passed. The native workflow merged that exact head as 6f3e8c77bb892f4ba83d6e55301a5805f1d993ba and completed cleanup. The historical profiling measurements above remain historical; no new Gateway performance claim is made.

@steipete steipete self-assigned this Sep 21, 2026
@steipete
steipete marked this pull request as ready for review September 21, 2026 11:03
@clawsweeper

clawsweeper Bot commented Sep 21, 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.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime commands Command implementations docker Docker and sandbox tooling agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Sep 21, 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 21, 2026
@clawsweeper

clawsweeper Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 21, 2026, 7:10 AM ET / 11:10 UTC.

ClawSweeper review

What this changes

Moves four persisted-session delivery readers into a module with type-only dependencies, updates callers and test mocks, and preserves public plugin SDK exports.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open: the import isolation remains useful and is absent from inspected main and the latest release. No actionable correctness defect was found; current-head validation is still underway.

Priority: P3
Reviewed head: 309866379668fe5abf0ac13a5cce5740de24f8c1

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, behavior-preserving extraction with complete caller migration and retained SDK exports; historical validation is clearly distinguished from pending current-head checks.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored internal refactor is exempt from external-contributor proof requirements. Historical worker-graph and Matrix profiling evidence addresses import cost, but does not establish current-head runtime results; no material authority change introduces an additional proof gate.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored internal refactor is exempt from external-contributor proof requirements. Historical worker-graph and Matrix profiling evidence addresses import cost, but does not establish current-head runtime results; no material authority change introduces an additional proof gate.
Evidence reviewed 9 items Pinned implementation preserves reader behavior: The introduced patch moves all four reader implementations unchanged into a module containing only type imports. Normalization remains in its existing module.
Public SDK contract preserved: The same four reader names remain exported through session-store-runtime with unchanged signatures and implementations; normalization exports remain available. This changes internal export sources, not the supported plugin API.
Still necessary on inspected main: Current main retains the four readers in delivery-context.shared.ts, alongside runtime normalization imports; store-entry.ts still imports its readers from that module.
Findings None None.
Security None None.

How this fits together

Session delivery readers extract stored channel, destination, origin, and route information for history, status, and delivery consumers. Separating these reads from route normalization reduces their runtime import dependencies without changing stored data or routing decisions.

flowchart LR
  A[Incoming routing facts] --> B[Existing route normalization]
  B --> C[Canonical session record]
  C --> D[Lightweight delivery readers]
  D --> E[History and status consumers]
  D --> F[Delivery consumers]
  D --> G[Existing plugin SDK exports]
Loading

Before merge

  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

Metric Value Why it matters
Historical worker import graph 291 → 277 reachable files; 5.69% fewer bytes The PR reports a smaller historical compiled graph, while explicitly claiming no demonstrated latency or RSS improvement.

Stored data model

Persistent data-model change detected: unknown-truncated-pull-files. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #154738
Summary: This PR implements the reader-isolation work explicitly requested by the paired open issue.

Members:

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

Technical review

Best possible solution:

Keep pure persisted-field reads independent of normalization runtime while retaining one normalization owner and the existing SDK contract.

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

Not applicable as a user-facing bug reproduction; current source directly shows pure readers sharing a module with runtime normalization imports.

Is this the best way to solve the issue?

Yes. Moving the unchanged readers and migrating their callers removes the dependency coupling without duplicating logic or changing the public SDK.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is an internal import-cost improvement with unchanged reader behavior and no demonstrated user-facing regression.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer-authored internal refactor is exempt from external-contributor proof requirements. Historical worker-graph and Matrix profiling evidence addresses import cost, but does not establish current-head runtime results; no material authority change introduces an additional proof gate.

Label justifications:

  • P3: This is an internal import-cost improvement with unchanged reader behavior and no demonstrated user-facing regression.
  • 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 maintainer-authored internal refactor is exempt from external-contributor proof requirements. Historical worker-graph and Matrix profiling evidence addresses import cost, but does not establish current-head runtime results; no material authority change introduces an additional proof gate.

Evidence

What I checked:

  • Pinned implementation preserves reader behavior: The introduced patch moves all four reader implementations unchanged into a module containing only type imports. Normalization remains in its existing module. (src/utils/delivery-context.read.ts:1, 309866379668)
  • Public SDK contract preserved: The same four reader names remain exported through session-store-runtime with unchanged signatures and implementations; normalization exports remain available. This changes internal export sources, not the supported plugin API. (src/plugin-sdk/session-store-runtime.ts:59, 309866379668)
  • Still necessary on inspected main: Current main retains the four readers in delivery-context.shared.ts, alongside runtime normalization imports; store-entry.ts still imports its readers from that module. (src/utils/delivery-context.shared.ts:251, e1ce0f531eff)
  • Latest-release comparison: The supplied latest release, v2026.9.5, also retains the readers in the normalization module; the proposed separation is not present there. (src/utils/delivery-context.shared.ts:251, ec9c1a13db89)
  • Three-way merge and caller cutover: Raw commit records confirm test-merge parents 6e70aff followed by the pinned PR head. Read-only source inspection of 154 merged files mentioning the former module found no named imports of the four removed reader exports; remaining dynamic references concern normalization helpers. (104ab5fa3b2a)
  • Proof scope and implementation boundary: The captured PR body reports historical compiled-worker graph reduction from 291 to 277 files and 5.69% fewer bytes, with effectively unchanged Matrix peak RSS. It explicitly distinguishes those measurements from current-head results. The measured worker is OpenClaw-owned; this patch changes delivery-reader imports and makes no Codex protocol or harness compatibility change requiring dependency-source verification. (extensions/codex/session-history.worker.ts:1, 309866379668)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vincentkoc: 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.

@steipete
steipete enabled auto-merge (squash) September 21, 2026 11:25
@steipete
steipete merged commit 6f3e8c7 into main Sep 21, 2026
289 of 290 checks passed
@steipete
steipete deleted the codex/lightweight-session-delivery-readers branch September 21, 2026 11:26
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash auto-merge.

vincentkoc added a commit that referenced this pull request Sep 21, 2026
* commit '0883394977d1fb3af657635967f6e447bd7fff9a': (72 commits)
  fix(ui): await scheduled rail layout in focus test
  fix(cron): keep healthy active runs from delaying job lists (#154421)
  fix(plugins): prevent config conflicts during legacy plugin installation (#154539)
  perf(gateway): reduce repeated session-list work (#154551)
  fix(tasks): retain admitted work across list retries (#154338)
  perf(gateway): speed up transcript artifact downloads (#154726)
  chore(ui): refresh control ui locales (#154580)
  fix(release): keep two extended-stable months eligible (#154777)
  fix(tests): avoid avatar descriptor reuse race (#154747)
  perf(plugins): reduce callback scope overhead (#154625)
  fix(ui): include final request time in completed work summaries (#149240)
  fix(ai): avoid retrying conflicting Responses terminal statuses (#149242)
  fix: identify malformed Code Mode JavaScript as input errors (#149222)
  fix(doctor): settle imported JSONL transcript leftovers (#154413)
  fix(cloud): restore node bootstrap with bundled browser runtime (#154654)
  test(ui): await publication state notifications (#154768)
  fix(plugins): keep unchanged plugins running across metadata refreshes (#151281)
  fix: keep chat panel accessibility targets within each pane (#153478)
  fix: forced Gateway restarts cancel healthy subagent work (#154300)
  improve: reduce session delivery reader imports (#154740)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 22, 2026
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 docker Docker and sandbox tooling 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: 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.

Session delivery readers eagerly load route-normalization dependencies

1 participant