Skip to content

fix(gateway): deliver activity-summary updates after compaction - #165024

Merged
steipete merged 1 commit into
mainfrom
dbasync/actsummary
Oct 4, 2026
Merged

steipete merged 1 commit into
mainfrom
dbasync/actsummary

Conversation

@steipete

@steipete steipete commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Activity clients could miss recap refreshes after successful session compaction even though the stored recap was fresh. Deferred row publication inherited the compaction or scheduler work scope, which closed before the notification reached subscribers. No later push arrived during the 110-second observation.

Why This Change Was Made

Keep accepted recap notifications with the existing Gateway subscription owner: retain any admitted root, detach only the producer's async cancellation scope, and join publication before clients and the row projection close. Reject new notifications once the scheduler/connection close prelude begins. Already accepted publication does not request new admission or wait behind suspension. Existing physical-store/generation checks, prepared-row publication, coalescing, and ordering remain in place.

User Impact

Subscribed Activity clients receive the updating and fresh recap notifications after compaction. This is release-note context for the user-visible fix. No schema, persistence, retention, SDK signature, configuration, or update migration changes are required.

Evidence

  • Real isolated Gateway and authenticated subscribed client, two synthetic turns and successful sessions.compact: baseline observed zero post-compaction recap pushes for 110.546 s, despite a fresh stored recap and a live connection. Candidate delivered exactly one fresh current recap push 66 ms after its stored update time (89.698 s after compaction), with matching text, timestamp, transcript generation, maxSeq=9, and coverage 4/4. Sequence order was updating → compact → current; no duplicate fresh-current notification. Both Gateways shut down cleanly.
  • Compaction correctly reused the recap text. The baseline harness's new-text matcher was too strict; the unchanged raw event trace and durable watermark independently establish the defect. Candidate proof uses the corrected freshness receipt matcher.
  • The regression failed on the base at expected subscriber delivery (zero sends). With the fix, all 34 subscription tests pass, including producer closure, coalescing, accepted-work shutdown joins, rejection after close, and subscriber filtering. Final command: pnpm test src/gateway/server-runtime-subscriptions.test.ts --maxWorkers=1 — 115.41 s wall; new regression 3.202 s; real-projection publication case 8.597 s, including its zero caller-thread SQL assertion. The baseline cold run took 349.93 s wall. An initial candidate run exposed a fixture-only assertion on unprojected compactionCount; it was corrected to the projected label.
  • Existing recap event and auxiliary-work shutdown tests passed (8 tests; 12.841 s and 20.801 s test time respectively). The initial combined focused invocation took 532.93 s wall, including cold compilation and the subsequently corrected fixture assertion.
  • Shared-registry/import-closure and publication-budget tests: 26 passed across 7 files, 227.11 s wall, all with --maxWorkers=1: test/scripts/runtime-process-build-graph.test.ts, src/auto-reply/reply/get-reply.imports.test.ts, src/state/openclaw-state.worker.imports.test.ts, src/config/sessions/session-history-read.imports.test.ts, src/config/sessions/session-transcript-reconcile.imports.test.ts, src/worker/worker.runtime-imports.test.ts, and src/gateway/session-event-prepared-row.test.ts.
  • node scripts/check-changed.mjs: passed, 3,677.39 s wall on the loaded host, including all 27 core test type graphs, lint, export scans, and repository guards.
  • Madge: 0 cycles, 85.70 s wall. Database worker ratchet passed against pinned base 68ebe61752ed33c688800172dc160ebff2586f18, 29.02 s wall. Inventory T1 895 → 895; notification publication is SQL-free, while recap-generation transcript reads remain with their existing owner.
  • Independent Codex P2 autoreview, pinned merge base and private temporary directory: scoped-clean, no actionable P0–P2 findings.
  • Production LOC: +9 / −1 / net +8. Added OPENCLAW_* names: 0. Exact-head CI run 37220922537 passed with no failed jobs: 407 s elapsed; changed-test shard durations were 79–151 s (including setup and cleanup). Per-test CI timing was not extracted.

Separate existing session-snapshot/transcript cancellation warnings remain in the synthetic workload; the activity-summary publication warnings are gone. This PR is scoped to recap notification ownership.

Overlap

Adjacent work includes #164989 (recap transcript reads) and #164922 (session lifecycle transactions), plus the sessauthtail, nativepatchtail, and delegateexec lanes. #162433 is the broad ownership-design umbrella. These changes keep minimal notification-owner hunks and do not restructure those lanes.

Released SDK surface check

Compared the production diff and latest release tag v2026.9.8, and checked src/plugin-sdk/**, src/plugins/runtime, and documented plugin subpaths. This PR changes no production function signature, sync/async contract, callback shape, or export. startGatewayEventSubscriptions remains internal; the changed Start callback type exists only in test support. No compatibility record or SDK type test is required.

@clawsweeper

clawsweeper Bot commented Oct 4, 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 docs Improvements or additions to documentation gateway Gateway runtime size: S labels Oct 4, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 Oct 4, 2026
@steipete

steipete commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 4, 2026, 1:48 PM ET / 17:48 UTC (Revision 3).

ClawSweeper review

What this changes

The PR keeps Activity recap notifications alive after compaction finishes, joins accepted notifications during Gateway shutdown, and adds lifecycle regression coverage and protocol documentation.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused fix: current main still inherits the producer’s cancellation scope, and the recorded Gateway run demonstrates recovered recap delivery. No actionable patch defect was found.

Priority: P2
Reviewed head: 240a016dd0c804a43e4333de877b890c05a9fcc1

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with convincing runtime evidence, meaningful lifecycle coverage, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The recorded isolated Gateway and authenticated subscribed client exercise the changed subscription publication path after sessions.compact: candidate delivers one fresh recap with matching stored metadata where baseline delivered none. Lifecycle regressions supplement this runtime receipt; no stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The recorded isolated Gateway and authenticated subscribed client exercise the changed subscription publication path after sessions.compact: candidate delivers one fresh recap with matching stored metadata where baseline delivered none. Lifecycle regressions supplement this runtime receipt; no stored-data contract changes.
Evidence reviewed 9 items Pinned introduced change: The introduced production change rejects notifications after close begins, retains existing Gateway root work, detaches the producer’s async work scope, and tracks publication in the existing shutdown join.
Still necessary on current main: Fetched main retains the original direct publication callback without the introduced close guard or scope detachment. The PR remains open at the reviewed head; no merged replacement is established.
Actual merge preserves the focused change: The verified test merge versus its pinned main parent contains the same production fix; base-branch changes are not attributed to this PR.
Findings None None.
Security None None.

How this fits together

The Gateway generates session recaps and publishes their updated session rows to subscribed Activity clients. Its subscription owner coordinates notification delivery with session generation checks and shutdown.

flowchart TD
  A[Compaction or scheduled recap] --> B[Recap state changes]
  B --> C{Gateway accepting notifications?}
  C -->|Yes| D[Subscription-owned publication]
  C -->|No| E[Notification rejected]
  D --> F[Prepare current session row]
  F --> G[Filter recipients and send update]
  D --> H[Shutdown joins accepted work]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +8, Tests +94, Docs +2. Total +104 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 9 1 +8
Tests 2 98 4 +94
Docs 1 4 2 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 111 7 +104

Review metrics

None.

Technical review

Best possible solution:

Keep recap publication with the existing subscription owner while preserving generation checks, recipient filtering, coalescing, and shutdown settlement.

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

Yes: the recorded isolated-Gateway compaction scenario and baseline-failing regression identify a concrete reproduction path, and current main retains the affected callback. This review inspected source and evidence without executing the scenario.

Is this the best way to solve the issue?

Yes: the patch repairs cancellation custody in the existing subscription owner and preserves the existing publication and authorization boundaries.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This repairs missed Activity recap refreshes after compaction without changing core turn execution or stored data.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The recorded isolated Gateway and authenticated subscribed client exercise the changed subscription publication path after sessions.compact: candidate delivers one fresh recap with matching stored metadata where baseline delivered none. Lifecycle regressions supplement this runtime receipt; no stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The recorded isolated Gateway and authenticated subscribed client exercise the changed subscription publication path after sessions.compact: candidate delivers one fresh recap with matching stored metadata where baseline delivered none. Lifecycle regressions supplement this runtime receipt; no stored-data contract changes.

Evidence

What I checked:

  • Pinned introduced change: The introduced production change rejects notifications after close begins, retains existing Gateway root work, detaches the producer’s async work scope, and tracks publication in the existing shutdown join. (src/gateway/server-runtime-subscriptions.ts:149, 240a016dd0c8)
  • Still necessary on current main: Fetched main retains the original direct publication callback without the introduced close guard or scope detachment. The PR remains open at the reviewed head; no merged replacement is established. (src/gateway/server-runtime-subscriptions.ts:146, 83f4c296109b)
  • Actual merge preserves the focused change: The verified test merge versus its pinned main parent contains the same production fix; base-branch changes are not attributed to this PR. (src/gateway/server-runtime-subscriptions.ts:149, 94cf75f12a83)
  • Real Gateway delivery proof: The captured PR body records an isolated Gateway and authenticated subscribed client exercising two synthetic turns and sessions.compact. Baseline produced no post-compaction recap pushes over 110.546 seconds; candidate delivered exactly one fresh current recap 66 milliseconds after its stored update, with matching generation, watermark, text, and coverage. Both Gateways shut down cleanly. This is reported runtime evidence, not a reviewer-executed run. (240a016dd0c8)
  • Lifecycle regression: The new test exercises producer closure, coalesced latest-row delivery, rejection after close, shutdown settlement, and subscriber filtering through the actual subscription and broadcaster owners. The existing real-projection case additionally asserts zero caller-thread SQL. The body reports baseline failure and 34 passing candidate subscription tests. (src/gateway/server-runtime-subscriptions.activity-summary.test-support.ts:36, 240a016dd0c8)
  • Generation and recipient safeguards: Publication still checks the captured session generation before broadcasting. The unchanged broadcaster checks current client membership, event scopes, and recipient access, while session projection revalidates current rows. Detachment changes cancellation custody rather than granting recipient authorization. (src/gateway/session-activity-summary-events.ts:31, 240a016dd0c8)

Likely related people:

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

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-04T17:36:15.601Z sha 240a016 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-04T17:42:29.950Z sha 240a016 :: needs maintainer review before merge. :: none

@clawsweeper

clawsweeper Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete
steipete merged commit bd6416c into main Oct 4, 2026
145 of 147 checks passed
@steipete
steipete deleted the dbasync/actsummary branch October 4, 2026 18:16
@steipete

steipete commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant