Skip to content

refactor(gateway): reuse native workspace and lifecycle facts - #177670

Merged
steipete merged 1 commit into
mainfrom
deslop/z02-37-workspace-bookkeeping-20261015
Oct 19, 2026
Merged

steipete merged 1 commit into
mainfrom
deslop/z02-37-workspace-bookkeeping-20261015

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Gateway workspace mutations wrap their existing native operation receipt in a second UUID/domain/source publication protocol with no independent consumer. Several advisory paths also repeat private copies, stale-observation ordering or settlement already owned elsewhere. Use the existing owners and remove those duplicate layers.

This recovers the individually qualified old residue onto current main, without reviving the deleted presence-summary owner. Production delta: 93 net lines removed across 14 production files (21 total changed files). No protocol, config, persisted schema, dependency, permission, retention or SDK contract changes. Phase E standalone memory backend and all its machinery/tests are untouched.

Best-effort tradeoffs accepted

Evidence

Independent complete-diff P0–P2 review: scoped-clean (.98), with 13 explicit intact determining-owner datasets. Current focused proof: 296 passing tests, two existing host-dependent skips and one investigated failure across 14 selected owner files. The checkpoint-stop case expected the original stop error but received OPENCLAW_STATE_LEASE_ABORTED caused by the caller's 1-second deadline. The narrow head replay reproduced it; a serial exact-base replay at e75403f reproduced the same stopped-case error and also reached that deadline in the non-stopped case. No assertion, timeout or skip was changed. This is baseline reproduction, not a claimed repair or a passing suite.

Targeted native types pass (11.25 seconds), typed changed-file lint passes (60.52 seconds), formatting passes, and the timeout-race ratchet passes without allowance changes. Mandatory suppression audit passes all 14 cases (23.20 seconds including wrapper). Earlier residue proof is historical, not current acceptance. Exact-head PR CI will be the broad gate. No live deployment, provider, device or channel claim.

@clawsweeper

clawsweeper Bot commented Oct 19, 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: M labels Oct 19, 2026
@steipete
steipete marked this pull request as ready for review October 19, 2026 19:53
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 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-19T20:00:33.495053Z 466a050 Draft marked ready
ℹ️ 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.

@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: 466a05068f

ℹ️ 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".

Comment on lines +183 to +184
if (result?.tlsFingerprint) {
verified = { fingerprint: result.tlsFingerprint, endpoint };

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 Preserve the newest TLS pin across overlapping probes

When two probes overlap a TLS certificate rotation and the request using the old certificate completes after one using the replacement, this unconditional assignment restores the old fingerprint as verified. Subsequent probes made while the certificate file is unavailable or another replacement is staged then trust only that stale fallback and return null against the healthy new listener, which can make restart/update readiness report the Gateway as unreachable. Keep the certificate-observation generation ordering when updating verified rather than ordering it by HTTP response completion.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 19, 2026
@clawsweeper

clawsweeper Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR simplifies Gateway workspace receipts, delivery lifetimes, advisory refreshes, and cleanup by reusing existing owners.

Example: A Talk catalog refresh finishes successfully after six seconds.

  • Before: A warm catalog keeps its previous snapshot because the refresh exceeded five seconds.
  • After: The successful refresh replaces the advisory snapshot while current session authorization remains enforced.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is coherent and source-reviewed, with focused production-owner test evidence; confidence remains limited to that validation.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored refactor is outside the ordinary contributor proof gate; supplied evidence reports focused worker, TLS, delivery, catalog, and lifecycle tests without claiming a current live deployment.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes
User problem: No new user-facing failure is claimed; duplicate Gateway bookkeeping increases maintenance cost around existing workspace and lifecycle behavior.
Reason: The maintainer-authored direction removes redundant machinery and explicitly records the changed edge cases, while preserving the determining owners.

Merge readiness

✅ Ready for maintainer review

Keep this maintainer-authored PR open: it removes duplicate bookkeeping using existing owners, and no actionable introduced defect was found beyond the explicitly accepted tradeoffs.

Priority: P3
Reviewed head: 466a05068f9baa04d619759119fdfbeb9a3ff125

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No current shipped-Gateway scenario is supplied; the reported validation exercises focused owner suites rather than an end-to-end deployment.
Agent review details

How this fits together

Gateway owners receive RPCs, workspace mutations, stream publications, and maintenance requests, then produce client responses, transport writes, committed workspace facts, and cleanup outcomes.

flowchart TD
  A[RPCs and runtime events] --> B[Gateway owners]
  B --> C[Workspace worker]
  C --> D[Database transaction]
  D --> E[Native commit receipt]
  E --> B
  B --> F[Client transport]
  B --> G[Scheduler cleanup]
Loading

Technical review

Best possible solution:

Retain the smaller implementation, its explicit best-effort tradeoffs, and the existing authority, native settlement, and shutdown owners.

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

This is a refactor rather than a reported bug; source inspection verifies the changed paths, without executing target code.

Is this the best way to solve the issue?

The change follows the smallest complete approach: remove duplicate bookkeeping while retaining the existing transaction, transport, validation, and scheduler owners.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Workspace committed-row publication keeps the original intent (7303989: Recover exact native committed rows after lost worker replies instead of reconstructing stale caller state.)
  • TLS certificate observation ordering changes intended behavior with a stated reason (e2c3eaa: Retain the verified replacement pin across concurrent certificate observations and response completion orders.)
  • Live-text delivery lifetime changes intended behavior with a stated reason (fc1ec4e: Keep ordered queues, byte reservations, retirement, and authority checks scoped to connection delivery.)
  • Narration delivery lifetime changes intended behavior with a stated reason (d769e31: Pace sidebar snapshots while flushing terminal text and preserving foreground and authorization contracts.)
  • Talk catalog refresh deadline changes intended behavior with a stated reason (4b0eb92: Serve retained advisory snapshots without awaiting slow provider readiness and preserve one refresh per selection.)
  • Maintenance drainage keeps the original intent (3b16db7: Run managed-worktree cleanup in the background with capacity protection, progress, and lifecycle drainage.)
  • Terminal constructor options changes intended behavior with a stated reason (052efb3: Consolidate output batching and flow control in one controller; its production caller supplies an inline options object.)
  • Cron plugin job copying keeps the original intent (c62c2d9: Map internal jobs into plugin-facing copies; required schedule and payload fields remain cloned.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned introduction and current main: Reviewed the introduced merge-base-to-head hunks; fetched main retains the prior implementations in the central changed owners, so this remains distinct work. (466a05068f9b)
  • Recorded owner decisions: The maintainer-authored body explicitly accepts completion-ordered TLS fallback, immutable client lifetimes, late advisory catalog publication, and removal of redundant internal correlation and copying. The full body was read; supplied capture identity is sourceRevision 0737f5b75cd4898fa49c49ab7aeaf0dc47700ab1490b11d1c9008829225ec5e1. (466a05068f9b)
  • Workspace authority and exact recovery retained: Mutation transactions retain reconciliation custody, commit-time lease checks, registry predicates, and native COMMIT receipts; recovery adopts exact matching committed rows only after completed settlement. This preserves the central guarantee established by fix: preserve approval and workspace state after lost worker replies #168094. (src/gateway/worker-environments/local-workspace-store.worker.ts:30, 466a05068f9b)
  • Accepted TLS review concern: The existing review's stale-fallback scenario is reachable, but precisely matches the tradeoff expressly accepted in the current body; exact peer fingerprint checks and endpoint isolation remain. The original ordering rationale was verified in feat(gateway): renew TLS certificates without restarting listeners #146267. (src/gateway/local-http-probe.ts:184, 466a05068f9b)
  • Existing lifecycle owners cover removed bookkeeping: The scheduler retains running jobs through cancellation and joins their returned promises; authenticated WebSocket setup binds a transport to each client, while delayed broadcasts still recheck membership, scopes, subscriptions, and session visibility. (src/gateway/worktree-maintenance.ts:132, 466a05068f9b)
  • Validation and CI disposition: The body reports focused owner tests and static checks, explicitly disclosing a checkpoint deadline failure reproduced on the exact base. Live reads show PostgreSQL conformance still running and openclaw/ci-gate pending; no diff-caused failing required check was established. (466a05068f9b)

Likely related people:

  • Peter Steinberger: Raw commit cd326f9 adds src/gateway/worker-environments/local-workspace-store.ts:94 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: cd326f915580; files: src/gateway/worker-environments/local-workspace-store.ts)
  • Mariano: Raw commit ef95975 adds src/gateway/node-pending-work.ts:98 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: ef95975411a9; files: src/gateway/node-pending-work.ts)

PR surface

Source -93, Tests +43, Docs 0. Total -50 across 21 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 14 53 146 -93
Tests 6 115 72 +43
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 21 169 219 -50

Review metrics

Metric Value Why it matters
Production versus test LOC Production +53/-146; tests +115/-72 Production shrinks by removing duplicate bookkeeping; test growth chiefly covers committed deletion, oversized lost-reply recovery, and RPC TTL admission.

Labels

Label changes:

  • add P3: This is maintenance work with no established urgent user-facing defect.
  • add merge-risk: 🚨 availability: Overlapping TLS probes can retain an older verified fallback and temporarily reject a healthy listener during another staged replacement; the maintainer explicitly accepts this recoverable tradeoff.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: This is maintenance work with no established urgent user-facing defect.
  • merge-risk: 🚨 availability: Overlapping TLS probes can retain an older verified fallback and temporarily reject a healthy listener during another staged replacement; the maintainer explicitly accepts this recoverable tradeoff.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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 19, 2026, 4:10 PM ET / 20:10 UTC.

@steipete
steipete merged commit 2cc639d into main Oct 19, 2026
230 of 232 checks passed
@steipete
steipete deleted the deslop/z02-37-workspace-bookkeeping-20261015 branch October 19, 2026 20:21
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@vincentkoc

Copy link
Copy Markdown
Member

The removal of createDeferredCore's import in this PR leaves a live call in src/gateway/local-http-probe.test.ts (the native HTTP deadline test). This now blocks required CI for #167350.

Current-head CI https://github.com/openclaw/openclaw/actions/runs/39321423337 completed with two failing jobs:

  • check-test-types-core-4: line154 TS2304: Cannot find name 'createDeferredCore'; line178 also loses contextual typing (TS7006).
  • check-lint-core-1: line178 typescript(prefer-promise-reject-errors). The reported file-length diagnostics are warnings, not the failing cause.

The tested merge 4b5ac80b332ca77f603795ed1450927d9d70073d and its main parent contain the same offending blob cb50eabba3e6638baad1a3860e8f602449757f75. PR167350 does not edit this file; its head and frozen baseline both retain the import. Main at b61b0809c63792c23df5ef68bc303882e146c134 still has the missing import.

The scoped repair is to restore import { createDeferredCore } from "../shared/deferred.js";, then prove the existing test file and affected type/lint checks. No assertion, production behavior, or lint allowance needs changing. Routing this to main's maintainer recovery under the current contribution policy instead of opening a competing test-only PR. PR167350 remains unmerged pending canonical repair and fresh required CI; this attribution is not a gate waiver.

vincentkoc added a commit that referenced this pull request Oct 19, 2026
* commit '08e32fdb4df002c9d4eea158b855d6521dd1e916': (52 commits)
  test(gateway): restore local probe deferred import
  fix(agents): release prompt diagnostics for retired sessions (#177614)
  fix(release): tag restart plugin cohorts consistently (#177725)
  refactor(ui): inline single-caller detail requests (#177705)
  chore(i18n): refresh native locales (#177721)
  refactor(codex): drop unread private runtime reports (#177689)
  refactor(ui): consolidate static artwork registries (#177692)
  refactor(ui): derive settings schema analysis in the view (#177624)
  refactor(media): consolidate capability defaults and compression grids (#177665)
  refactor(auth): bind OAuth managers to native provider operations (#177676)
  refactor(ui): remove redundant component rendering layers (#177607)
  fix(ios): model sign-in is a permanent row under the composer instead of an item in the model menu (#166082)
  fix(agents): report failed secret input prompt delivery (#177688)
  refactor(ui): share chat message render contracts (#177668)
  fix(ui): settle model status after overlapping publication (#177667)
  refactor(gateway): reuse native workspace and lifecycle facts (#177670)
  refactor(runtime): rely on canonical async lifecycle owners (#177635)
  refactor: fold private operation helpers into their callers (#177655)
  refactor(ui): remove unused chat leaf element adapters (#177582)
  perf(talk): use published authority for foreign voice writes (#177533)
  ...
vincentkoc added a commit that referenced this pull request Oct 19, 2026
#167350)

* fix(pr): retain the admitted workflow across maintainer commands

* fix: refresh the reviewed correction baseline

Baseline-Refresh: a89bd166b79d54b343b93ad374f8ebfa4f3d1163

* fix(pr): preserve cold workflow admission and repository identity

* chore(pr): integrate canonical main CI repair

* commit '08e32fdb4df002c9d4eea158b855d6521dd1e916': (52 commits)
  test(gateway): restore local probe deferred import
  fix(agents): release prompt diagnostics for retired sessions (#177614)
  fix(release): tag restart plugin cohorts consistently (#177725)
  refactor(ui): inline single-caller detail requests (#177705)
  chore(i18n): refresh native locales (#177721)
  refactor(codex): drop unread private runtime reports (#177689)
  refactor(ui): consolidate static artwork registries (#177692)
  refactor(ui): derive settings schema analysis in the view (#177624)
  refactor(media): consolidate capability defaults and compression grids (#177665)
  refactor(auth): bind OAuth managers to native provider operations (#177676)
  refactor(ui): remove redundant component rendering layers (#177607)
  fix(ios): model sign-in is a permanent row under the composer instead of an item in the model menu (#166082)
  fix(agents): report failed secret input prompt delivery (#177688)
  refactor(ui): share chat message render contracts (#177668)
  fix(ui): settle model status after overlapping publication (#177667)
  refactor(gateway): reuse native workspace and lifecycle facts (#177670)
  refactor(runtime): rely on canonical async lifecycle owners (#177635)
  refactor: fold private operation helpers into their callers (#177655)
  refactor(ui): remove unused chat leaf element adapters (#177582)
  perf(talk): use published authority for foreign voice writes (#177533)
  ...

Co-authored-by: Vincent Koc <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 20, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 20, 2026
openclaw#167350)

* fix(pr): retain the admitted workflow across maintainer commands

* fix: refresh the reviewed correction baseline

Baseline-Refresh: a89bd166b79d54b343b93ad374f8ebfa4f3d1163

* fix(pr): preserve cold workflow admission and repository identity

* chore(pr): integrate canonical main CI repair

* commit '4f8617589b6c71d754171052b603fe534901bfa1': (52 commits)
  test(gateway): restore local probe deferred import
  fix(agents): release prompt diagnostics for retired sessions (openclaw#177614)
  fix(release): tag restart plugin cohorts consistently (openclaw#177725)
  refactor(ui): inline single-caller detail requests (openclaw#177705)
  chore(i18n): refresh native locales (openclaw#177721)
  refactor(codex): drop unread private runtime reports (openclaw#177689)
  refactor(ui): consolidate static artwork registries (openclaw#177692)
  refactor(ui): derive settings schema analysis in the view (openclaw#177624)
  refactor(media): consolidate capability defaults and compression grids (openclaw#177665)
  refactor(auth): bind OAuth managers to native provider operations (openclaw#177676)
  refactor(ui): remove redundant component rendering layers (openclaw#177607)
  fix(ios): model sign-in is a permanent row under the composer instead of an item in the model menu (openclaw#166082)
  fix(agents): report failed secret input prompt delivery (openclaw#177688)
  refactor(ui): share chat message render contracts (openclaw#177668)
  fix(ui): settle model status after overlapping publication (openclaw#177667)
  refactor(gateway): reuse native workspace and lifecycle facts (openclaw#177670)
  refactor(runtime): rely on canonical async lifecycle owners (openclaw#177635)
  refactor: fold private operation helpers into their callers (openclaw#177655)
  refactor(ui): remove unused chat leaf element adapters (openclaw#177582)
  perf(talk): use published authority for foreign voice writes (openclaw#177533)
  ...

Co-authored-by: Vincent Koc <[email protected]>
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 merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants