Skip to content

fix(gateway): retain observer slots until model work settles - #174262

Merged
vincentkoc merged 4 commits into
mainfrom
fix/session-observer-physical-settlement-20261016
Oct 16, 2026
Merged

vincentkoc merged 4 commits into
mainfrom
fix/session-observer-physical-settlement-20261016

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Session observer work can outlive a logical timeout, eviction, or replacement, allowing another request to reuse its slot before work and cleanup physically settle.

User Impact

The existing model-work limit holds through physical settlement. Canceled late results remain unpublished; waiting observers resume only when capacity is released.

Why This Change Was Made

Separate physical reservations from the logical observer-state map. Each digest has its own async-work scope, drained before releasing its reservation. Disposal waits for owned work without waiting on a shared parent scope.

No new configuration, timeout, concurrency default, route, or persistence schema. Abort-ignoring work retains capacity until settlement rather than allowing overlapping replacement work.

Evidence

  • Current head: 3cf474d3d12faf0fa0bf2076180ce55893d9f071. Exact-head CI completed successfully: 36 successful jobs, 26 skipped, no failures. The tested merge was ab32ffe66a9af178e1b24cb641769b2684fe245d into cfc5fcf02b6b1d5ff72b4fdfce4f82e9a982371a.
  • Observer test job: all 14 observer suites, 100 cases passed, including eight physical-settlement cases and five model-slot cases. Coverage includes eviction, unsubscribe, replacement, logical success/error with retained cleanup, late-result suppression, disposal, timer cleanup, and at most six physically active requests.
  • Settlement tests use the real runWithAsyncWorkResources and trackAsyncWork implementations. Standalone shared async-work scope/resources suites were not selected; no standalone execution is claimed. Their implementation is unchanged.
  • Lint, all five core test-type jobs, and packaged build passed. The build reused startup metadata; this is not a fresh root-help generation measurement or an explanation of the earlier root-help timeout.
  • The final one-line harness type correction follows the inspected Vitest 5.0.3 callback contract. Earlier test-only corrections wait for raw settlement, persistence, and terminal broadcast without weakening assertions. Source review, signing, formatting, syntax, and diff checks passed.
  • The production repair is unchanged from reviewed 54d962f0a8c82f83a6b4e87e1b45c3914691e726; its conflict resolution preserves main's utility-completion test setup. Production delta is +40 lines for physical ownership and cleanup joining; tests are counted separately.
  • The older review's conflict/draft concerns are resolved. The small slot-owner test remains because it directly checks the reservation contract alongside the stronger service lifecycle matrix. No live-provider throughput, cost, latency benchmark, or real-transport trace is claimed.

@vincentkoc vincentkoc self-assigned this Oct 16, 2026
@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.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: M labels Oct 16, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 16, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro 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

Retain observer model-work reservations through physical completion and cleanup, then resume waiting observer states.

Example: Six observer requests are active when session-0 is evicted and session-6 requests a digest.

  • Before: Session-6 can start while session-0's abort-ignoring request still occupies resources.
  • After: Session-6 waits until an existing request and its retained cleanup settle.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused design is supported by source inspection, with limited validation confidence.
Proof confidence 🦪 silver shellfish (2/6) This maintainer-authored internal scheduling repair is outside the ordinary contributor runtime-proof gate; the body explicitly says the mocked observer tests were not executed, and no changed-path Gateway or real-transport settlement trace is supplied.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Background session assessments can overlap beyond their intended limit when canceled work continues consuming resources.
Reason: The bounded repair restores the existing concurrency contract, and the maintainer-authored body explicitly accepts waiting for abort-ignoring work.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep this PR open: it addresses a current observer resource-accounting defect, and source review found no definite introduced bug; GitHub reports a conflict and the PR remains a draft.

Priority: P2
Reviewed head: 54d962f0a8c82f83a6b4e87e1b45c3914691e726

Before merge

  • Complete next step - Resolve GitHub's reported merge conflict and mark this draft ready when intended for landing.

Findings

None.

Tests

  • Low-value test src/gateway/session-observer-model-slots.test.ts: Remove the added helper-level reservation test: the new observer-service settlement matrix already covers retention after eviction, unsubscribe, and replacement through the stronger lifecycle boundary.
  • Missing end-to-end proof: No executed base-fail/head-pass regression or Gateway/real-transport trace demonstrates retained capacity, resumption, late-result suppression, and disposal.
Agent review details

How this fits together

The Gateway observer consumes agent activity and subscription state, runs bounded utility-model assessments, and publishes and persists session digests.

flowchart TD
  A[Agent activity and subscriptions] --> B[Observer lifecycle]
  B --> C[Logical model selection]
  C --> D[Physical reservations]
  D --> E[Completion and owned cleanup]
  E --> F[Digest publication and persistence]
  E --> G[Release capacity and resume waiting states]
Loading

Technical review

Best possible solution:

Keep physical reservations with the existing slot owner and join digest-owned cleanup before releasing capacity.

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

Source shows that aborting or evicting a logical observer can admit replacement work while the original completion or tracked cleanup remains active; no target code was executed during this review.

Is this the best way to solve the issue?

The repair uses the existing reservation and async-work owners, preserves publication checks, and avoids polling or a second scheduler.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: none.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit dd7f7ad adds src/gateway/session-observer-completion.ts:40 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: dd7f7ada7e0e; files: src/gateway/session-observer-completion.ts)
  • Vincent Koc: Raw commit a3b5ce6 adds src/gateway/session-observer-completion.ts:28 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a3b5ce6d2c7b; files: src/gateway/session-observer-completion.ts)
  • Rogério Chaves: Raw commit 8e544b9 adds src/gateway/session-observer-completion.ts:54 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 8e544b9d9989; files: src/gateway/session-observer-completion.ts)

PR surface

Source +40, Tests +244. Total +284 across 7 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 3 41 1 +40
Tests 4 258 14 +244
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 299 15 +284

Review metrics

Metric Value Why it matters
Production versus test LOC Production +41/-1 (net +40); tests +258/-14 (net +244) Production growth separates physical custody from logical selection; most test growth covers distinct settlement and lifecycle scenarios.

Labels

Label changes:

  • add P2: The defect permits background observer model work to exceed its intended resource bound after cancellation or eviction.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: The defect permits background observer model work to exceed its intended resource bound after cancellation or eviction.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Execute the focused observer suites and demonstrate the new regression failing on the base and passing on the repaired head.
  • Exercise delayed physical settlement through the production completion boundary with a real transport client.

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, 9:57 AM ET / 13:57 UTC.

@vincentkoc
vincentkoc force-pushed the fix/session-observer-physical-settlement-20261016 branch from 54d962f to 70707a1 Compare October 16, 2026 14:13
@vincentkoc
vincentkoc marked this pull request as ready for review October 16, 2026 14:13
@vincentkoc
vincentkoc merged commit 9c5f458 into main Oct 16, 2026
128 checks passed
@vincentkoc
vincentkoc deleted the fix/session-observer-physical-settlement-20261016 branch October 16, 2026 17:12
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Oct 16, 2026
…158510

* commit '236ceb85e92ac8cb5bdc58a4a70bd79cbebd1094': (24 commits)
  feat(decisions): run typed tasks with prepared model credentials (#157225)
  fix(gateway): retain observer slots until model work settles (#174262)
  refactor(ui): own assistant content subscriptions in Solid (#174035)
  refactor(logging): remove package and snapshot debug instrumentation (#174431)
  fix: show native Talk speech separately from completed answers (#172598)
  test(ui): forbid new controller host consumers (#174446)
  chore(deps): refresh dependencies with a seven-day cutoff (#174410)
  perf(ui): reduce idle native session catalog polling (#174404)
  refactor(test): remove unused Signal fixture overrides (#174445)
  fix: surface DNS zone and Linux camera read failures (#174424)
  fix(doctor): keep at most three standalone Doctor captures (#174415)
  perf(cron): reuse session writer for completed run alias cleanup (#174413)
  feat(database): legacy SQLite migrations complete before PostgreSQL port (#174399)
  perf(channels): avoid rereading ingress queue mutations (#174393)
  feat(control-ui): keep link readers scoped to their pane session (#173652)
  test(ui): wait for desktop widget placement before pinning (#174439)
  refactor(ui): compose remaining plugin classes (#174441)
  perf(control-ui): shrink transcript overscan and settle skipped row sizes synchronously (#173690)
  fix(sessions): quietly settle archived delivery endpoints (#174442)
  perf(sessions): keep config loading out of transcript workers (#174414)
  ...
vincentkoc added a commit that referenced this pull request Oct 16, 2026
…esafe-decision-native

* commit '236ceb85e92ac8cb5bdc58a4a70bd79cbebd1094': (24 commits)
  feat(decisions): run typed tasks with prepared model credentials (#157225)
  fix(gateway): retain observer slots until model work settles (#174262)
  refactor(ui): own assistant content subscriptions in Solid (#174035)
  refactor(logging): remove package and snapshot debug instrumentation (#174431)
  fix: show native Talk speech separately from completed answers (#172598)
  test(ui): forbid new controller host consumers (#174446)
  chore(deps): refresh dependencies with a seven-day cutoff (#174410)
  perf(ui): reduce idle native session catalog polling (#174404)
  refactor(test): remove unused Signal fixture overrides (#174445)
  fix: surface DNS zone and Linux camera read failures (#174424)
  fix(doctor): keep at most three standalone Doctor captures (#174415)
  perf(cron): reuse session writer for completed run alias cleanup (#174413)
  feat(database): legacy SQLite migrations complete before PostgreSQL port (#174399)
  perf(channels): avoid rereading ingress queue mutations (#174393)
  feat(control-ui): keep link readers scoped to their pane session (#173652)
  test(ui): wait for desktop widget placement before pinning (#174439)
  refactor(ui): compose remaining plugin classes (#174441)
  perf(control-ui): shrink transcript overscan and settle skipped row sizes synchronously (#173690)
  fix(sessions): quietly settle archived delivery endpoints (#174442)
  perf(sessions): keep config loading out of transcript workers (#174414)
  ...
vincentkoc added a commit that referenced this pull request Oct 16, 2026
…/decision-tool-v2-proof-20261016

* commit '236ceb85e92ac8cb5bdc58a4a70bd79cbebd1094': (24 commits)
  feat(decisions): run typed tasks with prepared model credentials (#157225)
  fix(gateway): retain observer slots until model work settles (#174262)
  refactor(ui): own assistant content subscriptions in Solid (#174035)
  refactor(logging): remove package and snapshot debug instrumentation (#174431)
  fix: show native Talk speech separately from completed answers (#172598)
  test(ui): forbid new controller host consumers (#174446)
  chore(deps): refresh dependencies with a seven-day cutoff (#174410)
  perf(ui): reduce idle native session catalog polling (#174404)
  refactor(test): remove unused Signal fixture overrides (#174445)
  fix: surface DNS zone and Linux camera read failures (#174424)
  fix(doctor): keep at most three standalone Doctor captures (#174415)
  perf(cron): reuse session writer for completed run alias cleanup (#174413)
  feat(database): legacy SQLite migrations complete before PostgreSQL port (#174399)
  perf(channels): avoid rereading ingress queue mutations (#174393)
  feat(control-ui): keep link readers scoped to their pane session (#173652)
  test(ui): wait for desktop widget placement before pinning (#174439)
  refactor(ui): compose remaining plugin classes (#174441)
  perf(control-ui): shrink transcript overscan and settle skipped row sizes synchronously (#173690)
  fix(sessions): quietly settle archived delivery endpoints (#174442)
  perf(sessions): keep config loading out of transcript workers (#174414)
  ...
vincentkoc added a commit that referenced this pull request Oct 16, 2026
…157433

* commit '3dd7f576829fd8ec1fd395acb59f3d4f9e999166': (24 commits)
  feat(decisions): run typed tasks with prepared model credentials (#157225)
  fix(gateway): retain observer slots until model work settles (#174262)
  refactor(ui): own assistant content subscriptions in Solid (#174035)
  refactor(logging): remove package and snapshot debug instrumentation (#174431)
  fix: show native Talk speech separately from completed answers (#172598)
  test(ui): forbid new controller host consumers (#174446)
  chore(deps): refresh dependencies with a seven-day cutoff (#174410)
  perf(ui): reduce idle native session catalog polling (#174404)
  refactor(test): remove unused Signal fixture overrides (#174445)
  fix: surface DNS zone and Linux camera read failures (#174424)
  fix(doctor): keep at most three standalone Doctor captures (#174415)
  perf(cron): reuse session writer for completed run alias cleanup (#174413)
  feat(database): legacy SQLite migrations complete before PostgreSQL port (#174399)
  perf(channels): avoid rereading ingress queue mutations (#174393)
  feat(control-ui): keep link readers scoped to their pane session (#173652)
  test(ui): wait for desktop widget placement before pinning (#174439)
  refactor(ui): compose remaining plugin classes (#174441)
  perf(control-ui): shrink transcript overscan and settle skipped row sizes synchronously (#173690)
  fix(sessions): quietly settle archived delivery endpoints (#174442)
  perf(sessions): keep config loading out of transcript workers (#174414)
  ...
vincentkoc added a commit that referenced this pull request Oct 16, 2026
…/decision-onnx-v2-proof-20261016

* commit '3dd7f576829fd8ec1fd395acb59f3d4f9e999166': (24 commits)
  feat(decisions): run typed tasks with prepared model credentials (#157225)
  fix(gateway): retain observer slots until model work settles (#174262)
  refactor(ui): own assistant content subscriptions in Solid (#174035)
  refactor(logging): remove package and snapshot debug instrumentation (#174431)
  fix: show native Talk speech separately from completed answers (#172598)
  test(ui): forbid new controller host consumers (#174446)
  chore(deps): refresh dependencies with a seven-day cutoff (#174410)
  perf(ui): reduce idle native session catalog polling (#174404)
  refactor(test): remove unused Signal fixture overrides (#174445)
  fix: surface DNS zone and Linux camera read failures (#174424)
  fix(doctor): keep at most three standalone Doctor captures (#174415)
  perf(cron): reuse session writer for completed run alias cleanup (#174413)
  feat(database): legacy SQLite migrations complete before PostgreSQL port (#174399)
  perf(channels): avoid rereading ingress queue mutations (#174393)
  feat(control-ui): keep link readers scoped to their pane session (#173652)
  test(ui): wait for desktop widget placement before pinning (#174439)
  refactor(ui): compose remaining plugin classes (#174441)
  perf(control-ui): shrink transcript overscan and settle skipped row sizes synchronously (#173690)
  fix(sessions): quietly settle archived delivery endpoints (#174442)
  perf(sessions): keep config loading out of transcript workers (#174414)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
…w#174262)

* fix(gateway): retain observer slots until model work settles

* test(gateway): await observer settlement boundaries

* test(gateway): join dormant terminal publication

* test(gateway): type observer persistence mock as async
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M 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