Skip to content

perf(sessions): fuse prompt and lifecycle worker requests - #174098

Merged
steipete merged 4 commits into
mainfrom
dbasync/sessfuse
Oct 16, 2026
Merged

steipete merged 4 commits into
mainfrom
dbasync/sessfuse

Conversation

@steipete

@steipete steipete commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Warm chat turns make separate worker round trips for pure session bookkeeping. Capture the immutable model-prompt projection inside the transcript worker, reduce Gateway lifecycle events directly against the current session row, and skip ACP metadata joins when the current session has no parent and therefore cannot require child-delivery suppression.

The lifecycle commit returns its failure/recovery facts on the existing receipt. Runtime publication and failure-transcript appends keep their existing order. Goal resumes and recovery-owner changes are merged from the current stored entry. Error rendering stays on the host so its redaction registry remains authoritative. Memory sessions retain equivalent receipt behavior.

Generic transcript/entry callbacks remain supported for nonserializable caller work. The normal model-prompt and lifecycle paths no longer use those prepare/commit round trips. No schema, retention, public SDK, update, service lifecycle, placement, audit timing, or cross-store commit changes.

Removed work and accepted edges

  • Model-prompt capture removes the separate prepare request and its duplicate admission check. A metadata edit before commit is incorporated from the worker's current message; the canonical row check and immutable-projection rule remain at commit.
  • Lifecycle persistence removes the host preparation request and snapshot handoff. Goal/recovery changes queued before commit are incorporated by the existing deterministic reducer; source and provider-review authority remain enforced.
  • Parentless delivery omits an irrelevant ACP metadata join. It still reads current parent fields; sessions with a parent still read current ACP metadata. Admission eligibility facts are not reused as delivery authority.

The final lifecycle/observer patches are not folded into completeTurn: terminal persistence drains before its admission closes and before reply accounting starts. Changing that ownership/publication boundary needs separate work. Observer-digest attribution for the remaining entry-only request is not claimed as measured proof.

Evidence

Three alternating baseline/candidate harness-v3 pairs completed against dc43a7e79cc3571b89663970a496c10bd60ef99b and reviewed head ad315b3e014ad7fee7f62aa108eff52a0981ea90 (the merged production/test blobs were verified equal). All six accepted workloads passed all 14 top-level turns, spawn, control RPCs, cron, compaction, 300-second connected idle, restart readiness, post-restart chat, and both clean shutdowns. Native SQL/prepare errors and missing causal coverage are zero; every fixture child exited. The frozen v3 harness was unchanged. Node 24.22.0 and the loaded SQLite 3.54.0 libraries were pinned and attested before/after every arm; compile caching was disabled. Fixture account provisioning is unmeasured, not zero SQL. Host load varied substantially: counts only, no latency claim.

Counts below are median [min–max]. Warm rows pool 30 turns per side; whole-workload rows contain three runs.

Metric Base Candidate
Warmed causal all-thread SQL 72 [72–78] 72 [72–87]
Warmed causal requests 25 [25–27] 23 [23–26]
Warmed causal MAIN SQL 0 [0–0] 0 [0–0]
Warmed raw-window all-thread SQL 72 [72–98] 72 [72–110]
Warmed raw-window requests 25 [25–30] 23 [23–30]
Warmed raw-window MAIN SQL 0 [0–9] 0 [0–9]
Whole-workload all-thread SQL 4541 [4512–4542] 4508 [4505–4552]
Whole-workload requests 1075 [1072–1081] 1053 [1041–1054]
Whole-workload MAIN SQL 307 [306–308] 307 [307–307]
T1 calls in changed files (retained sync SDK lookup) 1 1
T1 calls in fused owner operations 0 0

The warmed saving is two requests per turn (8%), with unchanged SQL. The 21-request target is not reached. The harness creates a parented durable session, so its two ACP metadata requests correctly remain; the parentless optimization is covered by focused owner tests and is not counted as a harness saving.

Warm operation family Base SQL / requests Candidate SQL / requests
Model-prompt rewrite (prepare + commit → modelPrompt) 5 / 2 5 / 1
Entry patch preparation 0 / 1 0 / 0
Entry patch commits 10 / 3 10 / 3
ACP metadata 0 / 2 0 / 2
Actor completion 4 / 1 4 / 1

Shared-read families are overlapping classifications. Per-warm medians are unchanged: exact-entry, actor hydration, entry-cache snapshot and watermark reads are zero; row facts are 2 SQL / 2 requests. Whole-workload medians and ranges are disclosed below (SQL / family-attributed requests / MAIN).

Whole-workload read family Base Candidate
exact-entry facts 29 [29–32] / 29 [29–32] / 0 [0–0] 29 [28–30] / 29 [28–30] / 0 [0–0]
actor hydration 6 [5–6] / 6 [5–6] / 0 [0–0] 6 [6–6] / 6 [6–6] / 0 [0–0]
entry-cache snapshots 24 [22–25] / 14 [13–14] / 0 [0–0] 27 [25–27] / 16 [14–16] / 0 [0–0]
row facts 55 [54–55] / 51 [50–51] / 0 [0–0] 54 [54–55] / 50 [50–51] / 0 [0–0]
watermark reads 4 [4–4] / 3 [3–3] / 0 [0–0] 4 [4–4] / 3 [3–3] / 0 [0–0]

Entry-cache snapshot work rises by 3 SQL / 2 requests at the whole-workload median, while total workload falls by 33 SQL / 22 requests. The first candidate warm turn can perform a real 5-SQL/1-request initialization reload. Traces show background memory-index DDL invalidation moving from before initialization caching on the first baseline to after caching on both initial candidate attempts. That is a supported timing explanation; the exact missed key is inferred because cache tokens/miss reasons were not traced. The fusion retains the final publication path. This work remains counted, and candidate scheduling effects are not ruled out.

Causal warm run-mean medians are also unchanged at 72.6 SQL, with requests 25.2 → 23.2. Raw warm run-mean medians are 74.8 → 76.1 SQL and 25.4 → 23.7 requests; their additional background work remains included. Pooled raw warm medians do not rise. Causal first-turn SQL medians are 223 → 223 (requests 64 → 62); causal post-restart SQL is 149 → 149 (requests 49 → 47).

Startup background work shifts between connect and first-turn windows. Combined windows below include every statement/request and show their distribution across adjacent phases. Boot/connect/first rises 3 SQL / 3 requests (0.16% / 1.16%); compaction/idle/shutdown falls, as does the whole workload. No extra pair was needed: all three pairs agree on the warm saving.

Combined raw window (SQL / requests / MAIN) Base Candidate
boot/connect/first 1826 [1759–1830] / 258 [246–260] / 201 [193–202] 1829 [1817–1869] / 261 [258–273] / 202 [193–202]
restart 813 [803–840] / 235 [234–236] / 92 [92–93] 807 [806–810] / 235 [232–241] / 92 [92–92]
compaction/idle/shutdown 263 [220–268] / 79 [75–84] / 9 [9–9] 219 [219–219] / 74 [74–75] / 9 [9–9]

One initial candidate attempt is excluded because restart chat.send timed out after a roughly 95-second main-thread stall correlated with a native file-watcher registration error. An unrelated standing-intent worker spent that interval waiting for host admission (2 ms of SQL). Relevant watcher/admission/shutdown owners are byte-identical to base, but the original cause remains unproven and is not called inherited or fixed. Its evidence is retained. One unchanged candidate retry passed, followed by the remaining alternating pairs; none of the three accepted candidates repeated that failure. A bounded external sample in the retry began after the turn succeeded and had no usable call graph.

Focused tests cover stored-message metadata preservation and immutable replay; queued goal resumes and recovery-owner updates; memory failure receipts; lifecycle restart/reopen and failure publication; current parent/ACP metadata changes during delivery. Two Codex review rounds are scoped-clean through P2. Formatting, type-aware lint for the repairs, and diff checks pass. The first focused Gateway run passed 127 cases. Its fixture repairs and the previously unrun files completed with 383 passing cases; the two remaining lifecycle fixture failures were traced to test-pool routing and import order, repaired, and both pass in the real database-worker pool. A separate fixture type now uses InternalSessionEntry for internal lifecycle fields.

Initial CI exposed a widened lifecycle status type, one static import cycle through the broad session barrel, missing wrapper inventory modules, and test-fixture typing/setup issues. The repair commit addresses these, shrinks the obsolete assertion baseline entry, and keeps the actual owner behavior unchanged. Final CI on ad315b3 (run 38892235838) passes production/test types, lint, source contracts, architecture/Madge, baseline/T1/dialect ratchets, PostgreSQL conformance, and all test jobs except the inherited transcript expectation below. Its aggregate CI gate is red solely for that inherited failure. The abandoned-recovery cleanup case also passes in final CI. The unrelated transcript catalog NO_REPLY assertion fails identically on pinned main 28f8cab. A separate abandoned-recovery cleanup failure passed its focused main reproduction; the candidate replay also passes. This is recorded as intermittent and is not classified as inherited or fixed.

Knip production and script scans pass with zero findings. The final full-tree rescan confirms its sole finding (ui/src/pages/chat/components/chat-message-group.test-support.ts: renderActivityGroup) is identical on main run 38881317413; the source, scan configs, runner, and lockfile match. Exact-base inventory and final CI confirm global T1 222 → 222 and dialect counts 0 → 0. The remaining changed-file T1 lookup serves the public deprecated resolveTranscriptSessionKeyBySessionId SDK contract through 2026-12-31; it is outside the fused worker operations. No SDK surface change or published-driver update cell applies.

Diff versus the pinned base: +1,163 / −606 total; production +802 / −567 (net +235). Most lifecycle projection code is moved from the Gateway into the shared pure reducer; production growth carries its committed failure/recovery facts through the existing durable and memory receipts.

Automatic review disposition: the proposed extra lifecycle-generation check is not added because Gateway close drains accepted lifecycle persistence before the sole production generation rotation; the existing source/terminal authority remains at commit. The parentless memory-session metadata join is a bounded follow-up under the two-round cap; this PR claims the skip only for durable sessions.

Capture model prompt projections and reduce lifecycle patches in their existing worker owners. Preserve committed failure/publication ordering and skip ACP joins when current parent fields cannot require child-delivery suppression.
@clawsweeper

clawsweeper Bot commented Oct 16, 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T11:17:47.801394Z ad315b3 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: XL labels Oct 16, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR combines prompt capture and lifecycle bookkeeping into worker commits and skips unnecessary ACP metadata reads.

Example: An existing chat session records the enriched prompt "Summarize today's notes".

  • Before: The host prepares the transcript change through a separate worker request before committing it.
  • After: One worker command reads the current message, preserves its metadata, and commits the immutable prompt projection.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The direction and ownership model are sound, but introduced fixture and extraction defects prevent a merge-ready assessment.
Proof confidence 🦪 silver shellfish (2/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its supplied evidence contains no completed warm-turn performance campaign or successful production-path lifecycle result.
Patch quality 🦪 silver shellfish (2/6) 3 actionable review findings remain.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Warm chat turns pay avoidable worker round trips for session bookkeeping.
Reason: The maintainer-approved direction removes identifiable redundant work while retaining existing persistence owners and callback contracts.

Merge readiness

⛔ Needs changes before merge - 3 items remain

Keep this PR open: the maintainer-directed optimization is useful, but three introduced test and wrapper defects block merge.

Priority: P2
Reviewed head: 5f1cf28aaa264994b03f5347cf5b1bbde07e5292

Before merge

  • Import the cancellation spy from the actual operation owner (P2) - This test still imports sessionAccessor from session-accessor.js, which does not export applySessionEntryTargetOperation. Every table case therefore throws at spyOn before exercising cancellation settlement; exact-head CI reports the same three failures. Import and spy on session-accessor.sqlite-entry.js, matching the production caller.
  • Prepare runtime configuration inside the new worker fixture (P2) - withOpenClawTestState resets runtime configuration, and its minimal scenario writes a config file without publishing a runtime snapshot. persistGatewaySessionLifecycleEvent synchronously calls getRuntimeConfig, so both new cases throw before reaching the worker commit. Exact-head CI records these failures. Publish the fixture configuration inside this callback before invoking lifecycle persistence.
  • Include the new lifecycle dependencies in the wrapper inventory (P2) - This eager import extends the runtime closure of session-entry-patch-operation.ts, which scripts/pr extracts through its explicit inventory. The inventory omits session-run-lifecycle-projection.ts and seven transitive dependencies, so extracted wrapper sources cannot resolve the new import. Exact-head wrapper-closure CI lists all eight missing paths. Add the required runtime closure to scripts/pr-lib/wrapper-components.txt.

Findings

  • [P2] Import the cancellation spy from the actual operation owner — src/gateway/session-lifecycle-cancellation.test.ts:67-69
  • [P2] Prepare runtime configuration inside the new worker fixture — src/gateway/session-lifecycle-state.worker.test.ts:19-20
  • [P2] Include the new lifecycle dependencies in the wrapper inventory — src/config/sessions/session-entry-patch-operation.ts:23-27

Tests

  • Missing end-to-end proof: The planned warm-turn comparison and restart/shutdown campaign has no completed results, and baseline-failure/head-success evidence is not supplied.
Agent review details

How this fits together

The session persistence layer receives transcript and run-lifecycle updates from the Gateway, commits them through durable workers or memory actors, and returns facts for runtime publication and failure reporting.

flowchart LR
  A[Gateway chat turn] --> B[Session operation adapter]
  B --> C[Durable worker]
  B --> D[Memory actor]
  C --> E[Committed facts]
  D --> E
  E --> F[Runtime publication and failure transcript]
Loading

Technical review

Best possible solution:

Keep the worker consolidation and repair the cancellation import, runtime-config fixture, and wrapper dependency inventory.

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

Source confirms the redundant baseline worker requests, and exact-head CI independently records the three introduced defects; no local execution was performed.

Is this the best way to solve the issue?

Using closed operations in the existing workers preserves one persistence owner and current-row reduction without adding configuration or a parallel storage path.

Full review comments:

  • [P2] Import the cancellation spy from the actual operation owner — src/gateway/session-lifecycle-cancellation.test.ts:67-69
    This test still imports sessionAccessor from session-accessor.js, which does not export applySessionEntryTargetOperation. Every table case therefore throws at spyOn before exercising cancellation settlement; exact-head CI reports the same three failures. Import and spy on session-accessor.sqlite-entry.js, matching the production caller.
    Confidence: 1
    Late finding: first raised on code an earlier review cycle already covered.
  • [P2] Prepare runtime configuration inside the new worker fixture — src/gateway/session-lifecycle-state.worker.test.ts:19-20
    withOpenClawTestState resets runtime configuration, and its minimal scenario writes a config file without publishing a runtime snapshot. persistGatewaySessionLifecycleEvent synchronously calls getRuntimeConfig, so both new cases throw before reaching the worker commit. Exact-head CI records these failures. Publish the fixture configuration inside this callback before invoking lifecycle persistence.
    Confidence: 1
    Late finding: first raised on code an earlier review cycle already covered.
  • [P2] Include the new lifecycle dependencies in the wrapper inventory — src/config/sessions/session-entry-patch-operation.ts:23-27
    This eager import extends the runtime closure of session-entry-patch-operation.ts, which scripts/pr extracts through its explicit inventory. The inventory omits session-run-lifecycle-projection.ts and seven transitive dependencies, so extracted wrapper sources cannot resolve the new import. Exact-head wrapper-closure CI lists all eight missing paths. Add the required runtime closure to scripts/pr-lib/wrapper-components.txt.
    Confidence: 1
    Late finding: first raised on code an earlier review cycle already covered.

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Worker-owned lifecycle and transcript mutation keeps the original intent (refactor(sessions): run lifecycle and deletion transactions in the agent executor (compound 3b) #164922: Move synchronous session SQL off the Gateway thread while preserving ownership, publication order, and arbitrary host callbacks.)
  • Immutable model-prompt projection keeps the original intent (6461c18: Preserve first-sent enriched prompt bytes across follow-ups and reopened sessions.)
  • Memory session ownership keeps the original intent (3de654b: Keep incognito entry and transcript state in the memory actor with committed-fact publication.)
  • ACP source custody keeps the original intent (1ac31be: Retain exact source and runtime ownership across awaited ACP reads and cleanup.)

Testing

Proof path: none.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/gateway/session-lifecycle-cancellation.test.ts src/gateway/session-lifecycle-state.worker.test.ts --maxWorkers=1
  • pnpm test test/scripts/eager-import-closure.test.ts -t 'PR wrapper inventory' --maxWorkers=1
  • pnpm tsgo:core
  • git diff --check

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 1ac31be adds src/acp/runtime/session-meta-read.ts:36 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 1ac31be00c20; files: src/acp/runtime/session-meta-read.ts)

PR surface

Source +235, Tests +249, Docs +14. Total +498 across 34 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 21 801 566 +235
Tests 12 282 33 +249
Docs 1 14 0 +14
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 34 1097 599 +498

Review metrics

Metric Value Why it matters
Production versus test LOC Production +801/−566; tests and fixtures +282/−33. Most production additions relocate the existing lifecycle reducer; additional code carries committed effects through durable and memory receipts.

Labels

Label changes:

  • add P2: This is a normal-priority performance improvement with focused test and tooling repairs.
  • add merge-risk: 🚨 automation: The new eager dependency is missing from the trusted PR wrapper extraction inventory, leaving that automation with incomplete runtime sources.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: This is a normal-priority performance improvement with focused test and tooling repairs.
  • merge-risk: 🚨 automation: The new eager dependency is missing from the trusted PR wrapper extraction inventory, leaving that automation with incomplete runtime sources.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 16, 2026, 6:33 AM ET / 10:33 UTC.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts agents Agent runtime and tooling labels Oct 16, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: beabffd44d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

contextClaimId: params.event.contextClaimId,
data: params.event.data,
},
currentLifecycleGeneration: getAgentEventLifecycleGeneration(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Revalidate lifecycle generation inside the queued commit

When this write waits behind an earlier SQLite operation while the Gateway lifecycle rotates, currentLifecycleGeneration retains the pre-wait value. The worker can consequently treat a restart-cancelled or recovery-fenced event from the retired generation as current and settle stale status/recovery state; the previous callback-based path read the generation after reaching the write FIFO. Resolve it at commit time or enforce the live generation in the synchronous pre-commit guard.

AGENTS.md reference: src/gateway/AGENTS.md:L29-L30

Useful? React with 👍 / 👎.

options: {
currentMetadata?: true;
/** Skip the join when the consuming projection cannot use ACP metadata. */
includeMetadata?: (entry: SessionEntry | undefined) => boolean;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor the metadata filter for memory sessions

When delivery handles a parentless incognito session, the new predicate returns false, but this function enters the memory branch before evaluating it. prepareMemoryAcpSessionEntryRead then unconditionally calls readAcpSessionMetaForEntries, so these deliveries still incur the shared-state worker/SQLite metadata join that this optimization removes for durable sessions; apply the predicate to the actor snapshot before performing that join.

AGENTS.md reference: AGENTS.md:L72-L74

Useful? React with 👍 / 👎.

@steipete

Copy link
Copy Markdown
Contributor Author

Reviewed the two automatic inline findings against the actual ownership paths at ad315b3.

The lifecycle-generation finding does not establish a reachable restart regression. The only production rotation is in prepareGatewayRestartIteration (src/cli/gateway-cli/run-loop-startup.ts:217), after the prior Gateway close completes (run-loop.ts:770, run-loop.ts:1106). That close awaits agentUnsub (src/gateway/server-close.ts:442), which joins handler dispatch and sessionLifecyclePersistence.drain() (src/gateway/server-runtime-subscriptions.ts:632). The persistence owner tracks the entire queued commit and receipt publication. Failed or timed-out close does not authorize an in-process successor. Claimed terminal writes also retain the existing assertTerminalAuthority in the source assertion, enforced by the worker's commit grant. Capturing the generation before the SQLite FIFO therefore does not let an accepted Gateway lifecycle write cross an ordinary restart. Adding another generation check would guard an artificial rotation during already-owned bookkeeping, rather than a demonstrated data-loss path. No production change made for this finding; an unowned caller manually rotating generations while bypassing Gateway shutdown remains outside this flow.

The memory-session metadata filter finding is a valid bounded optimization follow-up. This PR skips the join for durable parentless sessions; memory-session reads preserve their existing metadata behavior. Applying the predicate to the memory actor snapshot can remove that remaining join in separate work. No incognito saving is claimed. This is deferred under the task's two-review-round cap, which limits subsequent fixes to real P0/P1 issues.

The focused repaired lifecycle worker cases pass (2/2), and the previously failing abandoned-recovery cleanup case passes on both recent main and this candidate. That cleanup failure is recorded as intermittent, not proven inherited or fixed. The unrelated transcript NO_REPLY expectation fails identically on recent main and remains separately documented.

@steipete
steipete merged commit 5b1d81e into main Oct 16, 2026
165 of 170 checks passed
@steipete
steipete deleted the dbasync/sessfuse branch October 16, 2026 11:34
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
…74098)

Capture immutable model-prompt projections in one transcript-worker command and apply lifecycle reductions against the owner's current session entry without the host prepare round trip. Return committed failure and recovery facts on the existing receipt, preserving runtime publication and failure-transcript ordering.

Skip the ACP metadata join for current parentless sessions while retaining current parent and ACP checks for child delivery. Keep terminal lifecycle persistence separate from completeTurn because admission closure and reply accounting follow its durable commit.

No schema, public SDK, retention, or service lifecycle change. Release-note context: fewer session bookkeeping worker requests for ordinary chat turns, with durable and memory-session behavior preserved.
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 23, 2026
83e5309)

Fleet-gap CARRY cluster "superseded-turn tombstone" (group B: 83e5309). 🌻 ruled
(room msg 1563128144884662273) that D3a's yield is ported with it.

A turn superseded by a newer session writer was persisted with abortedLastRun: true. With
its delivery claim still on the row, the successor's admission opened a restart-recovery
cycle, and a message-tool-only room was tombstoned with no restart (#1462). The superseded
run keeps status "killed" but is no longer marked as an aborted last run.

Re-ported onto this tree's projection owner,
src/config/sessions/session-run-lifecycle-projection.ts; upstream 5b1d81e (openclaw#174098) moved
the line there from the fleet's gateway/session-lifecycle-state.ts. The fleet's test-harness
moves (410de31, 39dd408) only hosted its integration case, and the P0 fossil now covers
that.

Proof:
- session-lifecycle-state.test.ts 50/50, with the new "superseded by a newer session writer"
  row (status "killed", abortedLastRun false).
- main-session-restart-recovery.live-stop.test.ts P0 ("superseded end event (#1463 fossil
  shape) leaves the live session safe") goes RED at 8fd1fa9 to GREEN here.
- P1/P2 stay RED; they belong to the D3b port.

Refs #1475

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant