Skip to content

fix: keep automations running when someone renames a session group or edits sharing - #201434

Merged
obviyus merged 1 commit into
mainfrom
fix/keep-runs-across-session-list-updates
Nov 18, 2026
Merged

obviyus merged 1 commit into
mainfrom
fix/keep-runs-across-session-list-updates

Conversation

@obviyus

@obviyus obviyus commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Root cause: src/config/sessions/session-delivery-generation.ts:192 treats the unkeyed { all: true, scope: "sessions" } session-list notification as a stored-row invalidation, so one sidebar group rename or sharing edit retires the delivery generation of every in-flight run on the Gateway.

Related: #185085, #186361

What Problem This Solves

A scheduled automation, a restart-resumed reply or another background session turn can fail partway through with Session delivery generation is unavailable; retry after session storage is ready. when anyone renames or deletes a session group or edits session sharing, even in an unrelated chat. The run ends as an error and its reply is lost.

User Impact

User impact: renaming or deleting a session group, or changing who a session is shared with, no longer kills automations and background turns that are running in other sessions.

Why This Change Was Made

Group and sharing handlers publish an unkeyed session-list notification after their storage writers have already published the exact per-session facts. The sharing-preparation owner already treats that plain notification as harmless once its facts are retained (d53921a, "shared-session runs lose access after session list updates"). The delivery-generation lease is the other consumer of the same notification and still invalidated on it. It now applies the same rule: a plain sessions notification is ignored once the lease has retained facts, and every later check still reads the retained source and current facts. Notifications that carry factsInvalidated or a runtimeSession still invalidate, as before.

The change is in the lease, not in each publisher, so group rename, group delete and sharing edits are all covered without changing what clients receive.

Evidence

  • Production (Team Gateway, 14 days, read-only journal): 28 lines with this error. All of them come from session-event runs (cron lane=cron-nested / source=cron: 14, restart-recovery turns: 13, one webchat follow-up). The first attempt had been running for 19 s to 91 min before it failed, and several sessions failed in the same second, which points to one Gateway-wide invalidation rather than a per-session write. No exec-completion, subagent or channel-send callers.
  • Isolated Gateway, deterministic local Responses fixture, cron job bound to a session whose turn takes 30 s, sessions.groups.rename called mid-run. Observed lines: fix: keep automations running when someone renames a session group or edits sharing #201434 (comment)
    • main 3bc20e2 (source and dist): every run that overlapped a rename failed with Session target preparation outlived its attempt | admitted run authority is no longer active | Session delivery generation is unavailable and session event execution failed source=cron, the same lines Team logs.
    • this branch ff77fa1 (source and dist): all cron runs finish ok with the same renames.
    • control, main without the rename: the cron run finishes ok.
  • Regression: session-delivery-generation.native.test.ts emits the unkeyed sessions notification on a prepared lease; red on main, green here. The same test checks that a factsInvalidated notification still retires the lease.
  • Adjacent suites pass: delivery-generation diagnostics/incarnation/registry, sessions-sharing, sessions-groups, session-sharing-publication integration, sessions-rewind local-workspace handoff, sessions-mutations catalog-queue.

Merge danger

Two-way door: one guard in the lease, no stored state, schema or config. If it were wrong, a run could keep a delivery generation across a group or sharing edit, but every effect still re-reads the retained source and the current row facts (membership, category, entry and permission changes are published per session and keep invalidating). Blast radius: in-flight session-event runs (cron, restart resume, exec completions) during session-list edits.

Thanks @jorge-monalee and @hvhoon for the detailed reports of runs dying with this error.

…ifications

- Session group renames/deletes and sharing edits publish an unkeyed sessions catalog
  notification after their committed writers install row facts. Prepared delivery
  generations treated it as a row invalidation, so every in-flight cron, restart-recovery
  and session-event run on the Gateway failed with SESSION_DELIVERY_GENERATION_UNAVAILABLE.
- Mirror the sharing-preparation owner (d53921a): ignore the plain notification once
  facts are retained; factsInvalidated or runtimeSession notifications still invalidate.
@clawsweeper

clawsweeper Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@obviyus

obviyus commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

Observed proof (isolated Gateways, deterministic local model fixture; private paths and session ids trimmed).

#185085 cluster (SESSION_DELIVERY_GENERATION_UNAVAILABLE) — PR #201434, head ff77fa14584982cddfe50afba6904f63de655ed3, base main 3bc20e28b022

== Production (Team, read-only journal via ssh journalctl; counts and normalized strings only; causes.py / timeline.py) ==
28 lines in 14 days (2026-11-15: 16, 2026-11-18: 12), 8 incident minutes. Builds: 2026.11.3-257759ae2be0 (11-15), 2026.11.5-f920a7e6941c (11-18, 59 commits behind current main).
By caller: cron session events 14 (lane=cron-nested 4, session-events source=cron 6, embedded-failed 4), restart-recovery turns 13 (lane=restart-recovery 9, embedded-failed 4), webchat followup 1. Exec-completion wake 0, subagent 0, channel send 0.
By what preceded: restart (SIGTERM restart 5-6 min earlier, restart-recovery turns) 12; compaction within 2 min 4 (11-15 19:44, 20:06); nothing notable 12 (11-18). Storage swap 0.
Shape: first attempt ran 19 s to 91 min before failing ("Session target preparation outlived its attempt | admitted run authority is no longer active | ..."), fallback candidate then fails in 1-2 ms (latched source failure); several sessions fail in the same second -> one Gateway-wide invalidation.

== Root cause ==
src/config/sessions/session-delivery-generation.ts:192 (`changed`, "all" branch): the unkeyed { all: true, scope: "sessions" } notification from emitSessionsChanged (src/gateway/server-methods/session-change-event.ts:430; producers sessions-groups.ts:126/214 rename/delete, sessions-sharing.ts:179) sets invalidated=true on every prepared delivery generation. Sibling owner session-sharing-preparation.ts:193 already ignores it (d53921ac1424).

== Unit regression (vitest-source) ==
session-delivery-generation.native.test.ts "retains generation facts across committed %s presentation changes":
  base 3bc20e28b022 ($B scratch): 2 failed — Expected undefined, Received SessionDeliveryGenerationUnavailableError (line 323)
  candidate ff77fa145849: 19/19 passed
Adjacent on candidate: sessions-sharing, sessions-groups, session-sharing-publication.integration, sessions-rewind.local-workspace-handoff, sessions-mutations.catalog-queue, delivery-generation diagnostics/incarnation/registry: passed.

== Gateway proof (run.sh + provider.mjs; isolated profile/state/port; cron job sessionTarget session:agent:main:p185-s, agentTurn whose model reply takes 30 s; sessions.groups.rename mid-run) ==
Tiers: main-groups1/cand-groups1 = source (ocx src; cand-groups1 = dirty tree with the fix, diff sha 87e860cb898b == ff77fa145849); base-groups2/cand-groups2/base-control1 = dist-nodts. Candidate also built full (ocx build --dts).
== main-groups1
label=main-groups1 tree=<worktree> head=3bc20e28b022265b9628fed44e06e8c15c8ee6ec dist=0 rounds=3 busy=30000
  mid-run RPC 19:33:08 sessions.groups.rename
  mid-run RPC 19:33:55 sessions.groups.rename
  mid-run RPC 19:34:42 sessions.groups.rename
  provider 2026-11-18T19:33:39.330Z busy(30000ms)
  provider 2026-11-18T19:34:40.136Z busy(30000ms)
  cron run error durationMs=30892 SessionDeliveryGenerationUnavailableError: Session delivery generation is unavailable; retry after session sto
  cron run error durationMs=30976 SessionDeliveryGenerationUnavailableError: Session delivery generation is unavailable; retry after session sto
  2026-11-19T01:04:09.366+05:30 [diagnostic] lane task error: lane=cron-nested durationMs=30834 error="Session target preparation outlived its attempt | admitted run authority is no longer active | Session delivery generation is unavailable; retry after session storage is ready. | SESSION_DELIVERY_GENERATION_UNAVAILABLE" errorName
  2026-11-19T01:04:09.386+05:30 [session-events] session event execution failed source=cron agentId=main sessionKey=agent:main:<s> eventId=<id> error="SessionDeliveryGenerationUnavailableError: Session delivery generation is unavailable; retry after session storage is ready."
  2026-11-19T01:05:10.232+05:30 [diagnostic] lane task error: lane=cron-nested durationMs=30770 error="Session target preparation outlived its attempt | admitted run authority is no longer active | Session delivery generation is unavailable; retry after session storage is ready. | SESSION_DELIVERY_GENERATION_UNAVAILABLE" errorName
  2026-11-19T01:05:10.283+05:30 [session-events] session event execution failed source=cron agentId=main sessionKey=agent:main:<s> eventId=<id> error="SessionDeliveryGenerationUnavailableError: Session delivery generation is unavailable; retry after session storage is ready."
RESULT main-groups1: cron_turns_reached_model=0 generation_unavailable_lines=6 session_event_failed=2
== base-groups2
label=base-groups2 tree=<main 3bc20e28b022 build> head=n/a dist=1 rounds=3 busy=30000
  mid-run RPC 19:50:04 sessions.groups.rename
  mid-run RPC 19:50:50 sessions.groups.rename
  mid-run RPC 19:51:37 sessions.groups.rename
  provider 2026-11-18T19:50:37.360Z busy(30000ms)
  cron run error durationMs=2174 SessionDeliveryGenerationUnavailableError: Session delivery generation is unavailable; retry after session sto
  cron run error durationMs=32804 SessionDeliveryGenerationUnavailableError: Session delivery generation is unavailable; retry after session sto
  2026-11-19T01:21:07.398+05:30 [diagnostic] lane task error: lane=cron-nested durationMs=32093 error="Session target preparation outlived its attempt | admitted run authority is no longer active | Session delivery generation is unavailable; retry after session storage is ready. | SESSION_DELIVERY_GENERATION_UNAVAILABLE" errorName
  2026-11-19T01:21:07.424+05:30 [session-events] session event execution failed source=cron agentId=main sessionKey=agent:main:<s> eventId=<id> error="SessionDeliveryGenerationUnavailableError: Session delivery generation is unavailable; retry after session storage is ready."
  2026-11-19T01:21:39.592+05:30 [diagnostic] lane task error: lane=cron-nested durationMs=2041 error="Session target preparation outlived its attempt | admitted run authority is no longer active | Session delivery generation is unavailable; retry after session storage is ready. | SESSION_DELIVERY_GENERATION_UNAVAILABLE" errorName=
  2026-11-19T01:21:39.604+05:30 [session-events] session event execution failed source=cron agentId=main sessionKey=agent:main:<s> eventId=<id> error="SessionDeliveryGenerationUnavailableError: Session delivery generation is unavailable; retry after session storage is ready."
RESULT base-groups2: cron_turns_reached_model=0 generation_unavailable_lines=6 session_event_failed=2 exec_wakes_reached_model=0 exec_completion_delivery_failed=0
== base-control1
label=base-control1 tree=<main 3bc20e28b022 build> head=n/a dist=1 rounds=3 busy=30000
  provider 2026-11-18T19:49:50.640Z busy(30000ms)
  provider 2026-11-18T19:50:24.672Z busy(30000ms)
  provider 2026-11-18T19:50:55.862Z busy(30000ms)
  provider 2026-11-18T19:51:26.994Z busy(30000ms)
  cron run ok durationMs=31721 
RESULT base-control1: cron_turns_reached_model=0 generation_unavailable_lines=0 session_event_failed=0 exec_wakes_reached_model=0 exec_completion_delivery_failed=0
== cand-groups1
label=cand-groups1 tree=<worktree> head=3bc20e28b022265b9628fed44e06e8c15c8ee6ec dist=0 rounds=3 busy=30000
  mid-run RPC 19:41:10 sessions.groups.rename
  mid-run RPC 19:41:56 sessions.groups.rename
  mid-run RPC 19:42:43 sessions.groups.rename
  provider 2026-11-18T19:41:40.901Z busy(30000ms)
  provider 2026-11-18T19:42:25.471Z busy(30000ms)
  provider 2026-11-18T19:43:10.666Z busy(30000ms)
  cron run ok durationMs=30886 
  cron run ok durationMs=31566 
  cron run ok durationMs=31134 
RESULT cand-groups1: cron_turns_reached_model=0 generation_unavailable_lines=0 session_event_failed=0
== cand-groups2
label=cand-groups2 tree=<worktree> head=ff77fa14584982cddfe50afba6904f63de655ed3 dist=1 rounds=3 busy=30000
  mid-run RPC 19:50:02 sessions.groups.rename
  mid-run RPC 19:50:48 sessions.groups.rename
  mid-run RPC 19:51:35 sessions.groups.rename
  provider 2026-11-18T19:50:34.838Z busy(30000ms)
  provider 2026-11-18T19:51:18.455Z busy(30000ms)
  provider 2026-11-18T19:52:02.875Z busy(30000ms)
  cron run ok durationMs=31051 
  cron run ok durationMs=32336 
  2026-11-19T01:22:34.283+05:30 [diagnostic] lane task error: lane=cron-nested durationMs=31542 error="agent run aborted for restart" errorName=AbortError taskKind=cron sessionKey=agent:main:<s> runId=74c6d75b-0585-4579-aa22-f7f00149929e modelFallbackCandidate=true
RESULT cand-groups2: cron_turns_reached_model=0 generation_unavailable_lines=0 session_event_failed=0 exec_wakes_reached_model=0 exec_completion_delivery_failed=0
== base-patch1
label=base-patch1 tree=<main 3bc20e28b022 build> head=n/a dist=1 rounds=2 busy=30000
  mid-run RPC 19:46:37 sessions.patch
  mid-run RPC 19:47:24 sessions.patch
  provider 2026-11-18T19:47:09.350Z busy(30000ms)
  provider 2026-11-18T19:47:55.031Z busy(30000ms)
  cron run ok durationMs=33441 
  2026-11-19T01:18:25.690+05:30 [session-events] session event execution failed source=cron agentId=main sessionKey=agent:main:<s> eventId=<id> error="AbortError: agent run aborted for restart"
RESULT base-patch1: cron_turns_reached_model=0 generation_unavailable_lines=0 session_event_failed=0
== cand-patch1
label=cand-patch1 tree=<worktree> head=3bc20e28b022265b9628fed44e06e8c15c8ee6ec dist=0 rounds=2 busy=30000
  mid-run RPC 19:44:04 sessions.patch
  mid-run RPC 19:44:52 sessions.patch
  provider 2026-11-18T19:44:37.028Z busy(30000ms)
  provider 2026-11-18T19:45:19.448Z busy(30000ms)
  cron run ok durationMs=33042 
  2026-11-19T01:15:50.501+05:30 [diagnostic] lane task error: lane=cron-nested durationMs=31317 error="agent run aborted for restart" errorName=AbortError taskKind=cron sessionKey=agent:main:<s> runId=634d37db-6034-4ed3-a5fc-0bd79d1878d0 modelFallbackCandidate=true
RESULT cand-patch1: cron_turns_reached_model=0 generation_unavailable_lines=0 session_event_failed=0
== main-exec1
label=main-exec1 tree=<main 3bc20e28b022 build> head=n/a dist=1 rounds=4 busy=10000
  provider 2026-11-18T19:53:32.380Z busy(10000ms)
  provider 2026-11-18T19:53:43.382Z other(P185_EXEC_DONE)
  provider 2026-11-18T19:53:44.653Z other(P185_EXEC_DONE)
  provider 2026-11-18T19:53:57.297Z busy(10000ms)
  provider 2026-11-18T19:54:07.565Z other(P185_EXEC_DONE)
  provider 2026-11-18T19:54:25.289Z busy(10000ms)
  provider 2026-11-18T19:54:35.558Z other(P185_EXEC_DONE)
  provider 2026-11-18T19:54:54.288Z busy(10000ms)
  provider 2026-11-18T19:55:04.823Z other(P185_EXEC_DONE)
RESULT main-exec1: cron_turns_reached_model=0 generation_unavailable_lines=0 session_event_failed=0 exec_wakes_reached_model=5 exec_completion_delivery_failed=0
== rel1007-exec1
label=rel1007-exec1 tree=<v2026.10.7 build> head=n/a dist=1 rounds=4 busy=10000
  provider 2026-11-18T20:00:12.430Z busy(10000ms)
  provider 2026-11-18T20:00:23.202Z other(P185_EXEC_DONE)
  provider 2026-11-18T20:00:23.554Z other(P185_EXEC_DONE)
  provider 2026-11-18T20:00:40.059Z busy(10000ms)
  provider 2026-11-18T20:00:50.372Z other(P185_EXEC_DONE)
  provider 2026-11-18T20:01:07.711Z busy(10000ms)
  provider 2026-11-18T20:01:18.294Z other(P185_EXEC_DONE)
  provider 2026-11-18T20:01:36.262Z busy(10000ms)
  provider 2026-11-18T20:01:47.003Z other(P185_EXEC_DONE)
  provider 2026-11-18T20:02:17.375Z busy(10000ms)
  2026-11-19T01:32:27.269+05:30 [diagnostic] lane task error: lane=background:core:skill-workshop durationMs=10039 error="/private<tmp> no longer current; lock removed/replaced; restart the Gateway." errorName=Error taskKind
  2026-11-19T01:32:27.270+05:30 [diagnostic] lane task error: lane=session:agent:main:<s> durationMs=10041 error="/private<tmp> no longer current; lock removed/replaced; restart the Gateway." errorName=Error taskKind=turn se
RESULT rel1007-exec1: cron_turns_reached_model=0 generation_unavailable_lines=0 session_event_failed=0 exec_wakes_reached_model=5 exec_completion_delivery_failed=0
== rel1007-groups1
label=rel1007-groups1 tree=<v2026.10.7 build> head=n/a dist=1 rounds=3 busy=30000
  mid-run RPC 20:03:10 sessions.groups.rename
  mid-run RPC 20:03:58 sessions.groups.rename
  mid-run RPC 20:04:44 sessions.groups.rename
  provider 2026-11-18T20:03:41.383Z busy(30000ms)
  provider 2026-11-18T20:04:26.030Z busy(30000ms)
  provider 2026-11-18T20:05:10.994Z busy(30000ms)
  cron run ok durationMs=30260 
  cron run ok durationMs=30633 
  2026-11-19T01:35:45.437+05:30 [diagnostic] lane task error: lane=cron-nested durationMs=34550 error="/private<tmp> no longer current; lock removed/replaced; restart the Gateway." errorName=Error taskKind=cron sessionKe
  2026-11-19T01:35:45.438+05:30 [diagnostic] lane task error: lane=session:agent:main:<s> durationMs=34552 error="/private<tmp> no longer current; lock removed/replaced; restart the Gateway." errorName=Error taskKind=cro
RESULT rel1007-groups1: cron_turns_reached_model=0 generation_unavailable_lines=0 session_event_failed=0 exec_wakes_reached_model=0 exec_completion_delivery_failed=0

@obviyus

obviyus commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 18, 2026
@clawsweeper

clawsweeper Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Preserve prepared session delivery generations across plain session-list notifications from group and sharing edits.

Example: Rename a session group while an unrelated scheduled agent turn awaits a 30-second model response.

  • Before: The turn fails with SESSION_DELIVERY_GENERATION_UNAVAILABLE.
  • After: The turn completes successfully despite the rename.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A narrow owner-level correction with shipped Gateway evidence, a reported red/green regression and no actionable correctness or security findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The exact-head proof exercises an isolated Gateway, session-bound cron execution and sessions.groups.rename during a delayed local Responses fixture: baseline runs fail, the no-rename control succeeds, and candidate runs complete without generation-unavailable errors; separate restart aborts are identified.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Renaming or deleting a session group, or editing sharing, can abort unrelated running automations and background replies.
Reason: The collaborator-authored direction repairs demonstrated user harm within the existing owner without adding configuration, persistence or a parallel execution path.

Merge readiness

✅ Ready for maintainer review

Keep this PR: it fixes a verified automation failure still present on fetched main, and the focused change has convincing Gateway evidence with no actionable findings.

Priority: P1
Reviewed head: ff77fa14584982cddfe50afba6904f63de655ed3

Before merge

None.

Findings

None.

Agent review details

How this fits together

Session-event admission retains a delivery lease; committed row publications and catalog notifications enter its listener, which determines whether background execution can continue.

flowchart TD
  A[Group or sharing edit] --> B[Committed storage writer]
  B --> C[Exact row facts]
  B --> D[Session list notification]
  C --> E[Delivery generation lease]
  D --> E
  E --> F[Background turn and delivery]
Loading

Technical review

Best possible solution:

Merge the focused lease correction after the existing exact-head gates pass, preserving committed-fact and source checks.

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

Supplied Gateway traces reproduce the rename-triggered failure on the pinned baseline, and fetched main retains the responsible code; this review executed no target code.

Is this the best way to solve the issue?

The smallest complete fix belongs in the existing lease listener: disregard the redundant catalog notification after retaining facts, while leaving exact publications and real invalidations effective.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Delivery-generation notification invalidation changes intended behavior with a stated reason (4f53213: Bind delayed delivery to its original conversation and reject genuinely replaced or revoked generations.)
  • Presentation-refresh regression coverage keeps the original intent (6c4541c: Keep retained execution alive through presentation notifications while preserving storage and lifecycle refusal.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Exact introduced change: The introduced diff adds a retained-facts exception only for plain unkeyed sessions notifications and extends the existing native regression with positive and invalidation controls. (src/config/sessions/session-delivery-generation.ts:198, ff77fa145849)
  • Fetched main still contains the failure: Fetched main still permanently invalidates the lease on the plain sessions notification; its two affected files are identical to the reproduced baseline. (src/config/sessions/session-delivery-generation.ts:207, ad550e953a9b)
  • Notification producer and existing sibling contract: Group rename/delete publish the broad notification after their storage operations, sharing edits publish it after scoped updates, and sharing preparation already exempts the same plain notification once facts are retained. (src/gateway/server-methods/session-change-event.ts:430, ff77fa145849)
  • Retained facts remain authoritative: The lease continues checking active state, database admission, retained generation facts and native policy; pending policy publications cannot supply stale settings. (src/config/sessions/session-delivery-generation.ts:499, ff77fa145849)
  • Shipped Gateway proof: The complete proof comment records baseline failures during sessions.groups.rename, a successful baseline without renames, successful candidate source runs, and successful built-candidate runs before a separately identified restart abort. It also records the regression failing on base and passing on head. Source identity: comment 6990134148, supplied SHA-256 3e65f39925278e2a2678b9455694ad2e1a3a83b961458cff0b168f7b4a52fb1a; the omitted tail was retrieved. (ff77fa145849)
  • History and original intent: The original delivery-custody work preserved the selected conversation and rejected genuine replacement; subsequent presentation-refresh repairs retained valid work. The sibling catalog exception was independently verified in commit d53921a. (src/config/sessions/session-delivery-generation.ts:188, ad550e953a9b)

Likely related people:

  • Peter Steinberger: Raw commit 6c4541c adds src/config/sessions/session-delivery-generation.ts:198 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6c4541cbf4f2; files: src/config/sessions/session-delivery-generation.ts)
  • Ayaan Zaidi: Raw commit 8d581e9 adds src/config/sessions/session-delivery-generation.ts:695 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 8d581e98c5b5; files: src/config/sessions/session-delivery-generation.ts)
  • Josh Avant: Raw commit 4f53213 adds src/config/sessions/session-delivery-generation.ts:109 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4f53213ad359; files: src/config/sessions/session-delivery-generation.ts)

PR surface

Source +10, Tests +4. Total +14 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 10 0 +10
Tests 1 4 0 +4
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 14 0 +14

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P1: An ordinary session-group edit can terminate unrelated active automations and lose their replies; the failure is reproduced through an isolated Gateway.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P1: An ordinary session-group edit can terminate unrelated active automations and lose their replies; the failure is reproduced through an isolated Gateway.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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 November 18, 2026, 3:11 PM ET / 20:11 UTC.

@obviyus

obviyus commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

Maintainer override: the only red on ff77fa1 is PostgreSQL conformance (2/4), case src/gateway/server-database-engine-cron.postgres.test.ts > Gateway PostgreSQL cron lifecycle > drains accepted cron finalization before graceful stop and preserves it on restart (https://github.com/openclaw/openclaw/actions/runs/44387141455/job/135095764425): the /readyz poll after SIGINT gets fetch failed / ECONNREFUSED instead of the 503 draining response. This PR did not cause it:

@obviyus
obviyus merged commit 04e8a7a into main Nov 18, 2026
138 of 141 checks passed
@obviyus
obviyus deleted the fix/keep-runs-across-session-list-updates branch November 18, 2026 20:39
@obviyus

obviyus commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

Merged in 04e8a7a. A session group rename or delete, or a sharing edit, no longer cancels every in-flight session-event run on the Gateway (cron runs, restart-recovery turns): the delivery-generation lease now ignores the broad sessions-changed notification once its facts are retained, the same rule the sharing preparation already uses. Notifications that really invalidate facts or the runtime session still do. Thanks @jorge-monalee and @hvhoon for the reports on #185085 and #186361; they stay open for the parts this PR does not cover.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 19, 2026
… edits sharing (openclaw#201434)

Root cause: src/config/sessions/session-delivery-generation.ts:192 treats the unkeyed `{ all: true, scope: "sessions" }` session-list notification as a stored-row invalidation, so one sidebar group rename or sharing edit retires the delivery generation of every in-flight run on the Gateway.

Related: openclaw#185085, openclaw#186361

## What Problem This Solves

A scheduled automation, a restart-resumed reply or another background session turn can fail partway through with `Session delivery generation is unavailable; retry after session storage is ready.` when anyone renames or deletes a session group or edits session sharing, even in an unrelated chat. The run ends as an error and its reply is lost.

## User Impact

User impact: renaming or deleting a session group, or changing who a session is shared with, no longer kills automations and background turns that are running in other sessions.

## Why This Change Was Made

Group and sharing handlers publish an unkeyed session-list notification after their storage writers have already published the exact per-session facts. The sharing-preparation owner already treats that plain notification as harmless once its facts are retained (4d6df47, "shared-session runs lose access after session list updates"). The delivery-generation lease is the other consumer of the same notification and still invalidated on it. It now applies the same rule: a plain `sessions` notification is ignored once the lease has retained facts, and every later check still reads the retained source and current facts. Notifications that carry `factsInvalidated` or a `runtimeSession` still invalidate, as before.

The change is in the lease, not in each publisher, so group rename, group delete and sharing edits are all covered without changing what clients receive.

## Evidence

- Production (Team Gateway, 14 days, read-only journal): 28 lines with this error. All of them come from session-event runs (cron `lane=cron-nested` / `source=cron`: 14, restart-recovery turns: 13, one webchat follow-up). The first attempt had been running for 19 s to 91 min before it failed, and several sessions failed in the same second, which points to one Gateway-wide invalidation rather than a per-session write. No exec-completion, subagent or channel-send callers.
- Isolated Gateway, deterministic local Responses fixture, cron job bound to a session whose turn takes 30 s, `sessions.groups.rename` called mid-run. Observed lines: openclaw#201434 (comment)
  - main d28eb7d (source and dist): every run that overlapped a rename failed with `Session target preparation outlived its attempt | admitted run authority is no longer active | Session delivery generation is unavailable` and `session event execution failed source=cron`, the same lines Team logs.
  - this branch ff77fa1 (source and dist): all cron runs finish `ok` with the same renames.
  - control, main without the rename: the cron run finishes `ok`.
- Regression: `session-delivery-generation.native.test.ts` emits the unkeyed `sessions` notification on a prepared lease; red on main, green here. The same test checks that a `factsInvalidated` notification still retires the lease.
- Adjacent suites pass: delivery-generation diagnostics/incarnation/registry, sessions-sharing, sessions-groups, session-sharing-publication integration, sessions-rewind local-workspace handoff, sessions-mutations catalog-queue.

## Merge danger

Two-way door: one guard in the lease, no stored state, schema or config. If it were wrong, a run could keep a delivery generation across a group or sharing edit, but every effect still re-reads the retained source and the current row facts (membership, category, entry and permission changes are published per session and keep invalidating). Blast radius: in-flight session-event runs (cron, restart resume, exec completions) during session-list edits.

Thanks @jorge-monalee and @hvhoon for the detailed reports of runs dying with this error.

Co-authored-by: Ayaan Zaidi <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 19, 2026
… edits sharing (#201434)

Root cause: src/config/sessions/session-delivery-generation.ts:192 treats the unkeyed `{ all: true, scope: "sessions" }` session-list notification as a stored-row invalidation, so one sidebar group rename or sharing edit retires the delivery generation of every in-flight run on the Gateway.

Related: #185085, #186361

## What Problem This Solves

A scheduled automation, a restart-resumed reply or another background session turn can fail partway through with `Session delivery generation is unavailable; retry after session storage is ready.` when anyone renames or deletes a session group or edits session sharing, even in an unrelated chat. The run ends as an error and its reply is lost.

## User Impact

User impact: renaming or deleting a session group, or changing who a session is shared with, no longer kills automations and background turns that are running in other sessions.

## Why This Change Was Made

Group and sharing handlers publish an unkeyed session-list notification after their storage writers have already published the exact per-session facts. The sharing-preparation owner already treats that plain notification as harmless once its facts are retained (d53921a, "shared-session runs lose access after session list updates"). The delivery-generation lease is the other consumer of the same notification and still invalidated on it. It now applies the same rule: a plain `sessions` notification is ignored once the lease has retained facts, and every later check still reads the retained source and current facts. Notifications that carry `factsInvalidated` or a `runtimeSession` still invalidate, as before.

The change is in the lease, not in each publisher, so group rename, group delete and sharing edits are all covered without changing what clients receive.

## Evidence

- Production (Team Gateway, 14 days, read-only journal): 28 lines with this error. All of them come from session-event runs (cron `lane=cron-nested` / `source=cron`: 14, restart-recovery turns: 13, one webchat follow-up). The first attempt had been running for 19 s to 91 min before it failed, and several sessions failed in the same second, which points to one Gateway-wide invalidation rather than a per-session write. No exec-completion, subagent or channel-send callers.
- Isolated Gateway, deterministic local Responses fixture, cron job bound to a session whose turn takes 30 s, `sessions.groups.rename` called mid-run. Observed lines: #201434 (comment)
  - main 3bc20e2 (source and dist): every run that overlapped a rename failed with `Session target preparation outlived its attempt | admitted run authority is no longer active | Session delivery generation is unavailable` and `session event execution failed source=cron`, the same lines Team logs.
  - this branch ff77fa1 (source and dist): all cron runs finish `ok` with the same renames.
  - control, main without the rename: the cron run finishes `ok`.
- Regression: `session-delivery-generation.native.test.ts` emits the unkeyed `sessions` notification on a prepared lease; red on main, green here. The same test checks that a `factsInvalidated` notification still retires the lease.
- Adjacent suites pass: delivery-generation diagnostics/incarnation/registry, sessions-sharing, sessions-groups, session-sharing-publication integration, sessions-rewind local-workspace handoff, sessions-mutations catalog-queue.

## Merge danger

Two-way door: one guard in the lease, no stored state, schema or config. If it were wrong, a run could keep a delivery generation across a group or sharing edit, but every effect still re-reads the retained source and the current row facts (membership, category, entry and permission changes are published per session and keep invalidating). Blast radius: in-flight session-event runs (cron, restart resume, exec completions) during session-list edits.

Thanks @jorge-monalee and @hvhoon for the detailed reports of runs dying with this error.

Co-authored-by: Ayaan Zaidi <[email protected]>

(cherry picked from commit 04e8a7a)

Co-authored-by: RomneyDa <[email protected]>
github-actions Bot pushed a commit to clawhaven/openclaw that referenced this pull request Nov 23, 2026
… edits sharing (openclaw#201434)

Root cause: src/config/sessions/session-delivery-generation.ts:192 treats the unkeyed `{ all: true, scope: "sessions" }` session-list notification as a stored-row invalidation, so one sidebar group rename or sharing edit retires the delivery generation of every in-flight run on the Gateway.

Related: openclaw#185085, openclaw#186361

## What Problem This Solves

A scheduled automation, a restart-resumed reply or another background session turn can fail partway through with `Session delivery generation is unavailable; retry after session storage is ready.` when anyone renames or deletes a session group or edits session sharing, even in an unrelated chat. The run ends as an error and its reply is lost.

## User Impact

User impact: renaming or deleting a session group, or changing who a session is shared with, no longer kills automations and background turns that are running in other sessions.

## Why This Change Was Made

Group and sharing handlers publish an unkeyed session-list notification after their storage writers have already published the exact per-session facts. The sharing-preparation owner already treats that plain notification as harmless once its facts are retained (d53921a, "shared-session runs lose access after session list updates"). The delivery-generation lease is the other consumer of the same notification and still invalidated on it. It now applies the same rule: a plain `sessions` notification is ignored once the lease has retained facts, and every later check still reads the retained source and current facts. Notifications that carry `factsInvalidated` or a `runtimeSession` still invalidate, as before.

The change is in the lease, not in each publisher, so group rename, group delete and sharing edits are all covered without changing what clients receive.

## Evidence

- Production (Team Gateway, 14 days, read-only journal): 28 lines with this error. All of them come from session-event runs (cron `lane=cron-nested` / `source=cron`: 14, restart-recovery turns: 13, one webchat follow-up). The first attempt had been running for 19 s to 91 min before it failed, and several sessions failed in the same second, which points to one Gateway-wide invalidation rather than a per-session write. No exec-completion, subagent or channel-send callers.
- Isolated Gateway, deterministic local Responses fixture, cron job bound to a session whose turn takes 30 s, `sessions.groups.rename` called mid-run. Observed lines: openclaw#201434 (comment)
  - main 3bc20e2 (source and dist): every run that overlapped a rename failed with `Session target preparation outlived its attempt | admitted run authority is no longer active | Session delivery generation is unavailable` and `session event execution failed source=cron`, the same lines Team logs.
  - this branch ff77fa1 (source and dist): all cron runs finish `ok` with the same renames.
  - control, main without the rename: the cron run finishes `ok`.
- Regression: `session-delivery-generation.native.test.ts` emits the unkeyed `sessions` notification on a prepared lease; red on main, green here. The same test checks that a `factsInvalidated` notification still retires the lease.
- Adjacent suites pass: delivery-generation diagnostics/incarnation/registry, sessions-sharing, sessions-groups, session-sharing-publication integration, sessions-rewind local-workspace handoff, sessions-mutations catalog-queue.

## Merge danger

Two-way door: one guard in the lease, no stored state, schema or config. If it were wrong, a run could keep a delivery generation across a group or sharing edit, but every effect still re-reads the retained source and the current row facts (membership, category, entry and permission changes are published per session and keep invalidating). Blast radius: in-flight session-event runs (cron, restart resume, exec completions) during session-list edits.

Thanks @jorge-monalee and @hvhoon for the detailed reports of runs dying with this error.

Co-authored-by: Ayaan Zaidi <[email protected]>

(cherry picked from commit 04e8a7a)

Release adaptation: Source guard/test unchanged; exact4-line regression allocation. Runtime native suite setup stalled before tests; proof pending, not validated.

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
… edits sharing (#201434)

Baseline adaptation: Keep retained leases on ordinary session-list notices; preserve explicit invalidation and live source checks in the shipped owner.

(cherry picked from commit 04e8a7a)

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
When neither the selected endpoint nor the model row declares input,
ClawRouter's fallback classified gpt-6.2-sol and gpt-6.2-astra as
text-only. Add both upstream IDs and cover them in the fallback test.

(cherry picked from commit 3bc20e2)

Release adaptation: Cite the original PR’s November 18, 2026 live ClawRouter image proof in the legacy fallback; exact upstream IDs, explicit modality precedence, and text-only behavior for unrecognized models are unchanged.

Follow-up audit: #205137’s catalog clock fixture is already equivalent (70a36ea), and #203898 is already integrated (fec6728). #207768 classifies catalog misses and #192450 adds Bedrock routing; neither is required by the exact-ID fallback. #201434 and #201415 mention the donor SHA as an unrelated verification baseline. Original #200878 has no additional follow-up reference at the pinned scan end.

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS 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.

1 participant