Skip to content

fix(gateway): keep chat metadata responsive across auth refresh - #139192

Merged
steipete merged 2 commits into
mainfrom
codex/qa-metadata-refresh-lifecycle-20260905
Sep 5, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/qa-metadata-refresh-lifecycle-20260905

Conversation

@steipete

@steipete steipete commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users reading chat metadata could wait indefinitely after a configured model owner failed and another owner's authentication refreshed successfully. Healthy auth publication could also produce a false chat metadata refresh failed warning when previously queued metadata work ran during the replacement window.

Why This Change Was Made

Metadata invalidation now revokes obsolete refresh work while preserving its existing replacement wait and shutdown ownership. The Gateway lifecycle distinguishes an owner that has not published yet from one whose publication is pending or has failed, so subordinate changes cannot erase a recorded failure and create an unowned wait. The canonical publication event still rebuilds fresh metadata; real preparation and publication failures remain visible.

This completes the owner boundary used by #123433. It does not change configuration, persistence, protocol, dependencies, or provider policy. Production LOC: +31/-25 (net +6) for the required initial/available/unavailable distinction and refresh ownership fencing. Tests: +370/-9.

User Impact

Chat metadata waits for the current publication and returns its result or recorded failure. Superseded background work cannot publish stale auth availability or fail a newer reader. Shutdown still joins outstanding preparation and projections.

Evidence

  • On unchanged d3386f151859443fe9dd589d7451ffde1554afd0, three complete suites produced exactly nine expected regression failures and 71 passing controls. The real prepared-owner composition reproduces the stranded reader after a prior worker failure followed by a successful main-only auth publication.
  • On this candidate, all 88 tests in seven complete suites pass: lifecycle, runtime preparation, real prepared-owner composition, shutdown, personal accounts, native sessions, and the Gateway RPC boundary.
  • Tests preserve initial missing-owner recovery, nested invalidation of an existing reader, current preparation/projection failures, stale auth fencing, failed-owner recovery, and shutdown joins. No new production test seam.
  • Managed independent Codex review through P2: scoped-clean, no actionable findings. Formatting and git diff --check pass; the normal pre-commit hook preserves the tested source bytes.
  • Uninstrumented compiled Gateway baseline: fresh and restarted synthetic QA-channel conversations each reproduced the warning; four replies and twelve metadata RPCs succeeded with both configured models available. The implicated source owners are byte-identical between that baseline and the current base. Candidate compiled Gateway replay passes: fresh and restarted cases each return two replies and five successful metadata RPCs, with both configured models available and zero refresh warnings. Full source/dist/package identity and owned shutdown checks pass. The initial complete changed gate and hosted CI found seven test-only lint errors; the follow-up normalizes Promise callbacks without changing assertions or production bytes. Fresh managed P2 review of that follow-up is scoped-clean. Final typed lint and both affected suites pass (37 tests); the complete changed gate passes in 211.945 seconds, and exact-head CI33976332511 is green on f0ca6cd52633e367721a4c5809ff1ca5d3e4abe8. All owned process groups were confirmed dead and proof archives downloaded and hash-verified.

Provenance: the warning predates the unrelated session-patch repair that exposed it during QA. The original introducing change is unproven; no causal attribution to that repair. The live evidence uses a real built Gateway and QA channel with a loopback synthetic provider, and does not establish production prevalence.

@clawsweeper

clawsweeper Bot commented Sep 5, 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 maintainer Maintainer-authored PR labels Sep 5, 2026
@steipete
steipete marked this pull request as ready for review September 5, 2026 15:44
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Sep 5, 2026
@clawsweeper

clawsweeper Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 5, 2026, 11:53 AM ET / 15:53 UTC.

ClawSweeper review

What this changes

Keeps chat metadata requests responsive during authentication refresh by preserving recorded publication failures and preventing obsolete refresh work from settling newer requests.

Merge readiness

✅ Ready for maintainer review

Keep open: current main still contains the reported defect. This protected maintainer PR provides a focused repair, and no blocking correctness findings were identified.

Priority: P2
Reviewed head: b701f4cd0fe6b7b2b1fa54d816aec9da7ccd532d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary repair with meaningful ordering regressions and no identified blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The external-contributor proof gate does not apply to this maintainer PR, and no material authorization change triggers an exception. The captured body reports fresh and restarted compiled Gateway metadata/auth-refresh replays with successful RPCs and no refresh warnings; these runs were not independently executed here.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The external-contributor proof gate does not apply to this maintainer PR, and no material authorization change triggers an exception. The captured body reports fresh and restarted compiled Gateway metadata/auth-refresh replays with successful RPCs and no refresh warnings; these runs were not independently executed here.
Evidence reviewed 8 items Current main still has the failure mechanism: Current main unconditionally invalidates metadata on subordinate changes, clearing the recorded failure and creating a replacement wait. Both production files have identical blobs at the PR merge base and fetched main, so the proposed repair remains necessary.
Publication owner explains the stranded wait: Authentication publication announces global readiness only when every configured owner is request-visible. A healthy agent can finish independently while a previously failed sibling prevents that announcement. These publication events and metadata generations are OpenClaw-owned; the introduced changes do not depend on a Codex runtime or protocol contract.
Refresh fencing preserves settlement and shutdown ownership: Invalidation advances the refresh version and detaches pending publication without discarding the replacement promise or tracked work. Version checks retire superseded preparation failures; current failures remain observable, and stop still joins outstanding work.
Findings None None.
Security None None.

How this fits together

Gateway chat metadata combines prepared model, authentication, and skill information for chat clients. Its lifecycle determines when requests receive current models and commands, wait for publication, or receive a recorded failure.

flowchart TD
  A[Model and authentication publication] --> C[Gateway metadata lifecycle]
  B[Skill and catalog changes] --> C
  C --> D{Generation state}
  E[Chat metadata request] --> D
  D -->|Ready| F[Models and commands]
  D -->|Replacing or failed| G[Wait or recorded error]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +6, Tests +349. Total +355 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 31 25 +6
Tests 3 358 9 +349
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 389 34 +355

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net +6 lines; tests net +349 lines Production growth represents the explicit lifecycle-state distinction and refresh fencing; test growth exercises ordering, failure retention, and recovery.

Technical review

Best possible solution:

Retain the publication-owned refresh flow; the six added production lines distinguish initial attachment from failure and fence obsolete work without adding a competing recovery path.

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

Yes, from source: settle one configured owner's failure, then refresh another owner's authentication while global publication remains unavailable. The new composition test encodes this sequence; no tests were executed during this read-only review.

Is this the best way to solve the issue?

Yes. Repairing invalidation and settlement at the metadata lifecycle preserves genuine failures and existing shutdown semantics; client retries or broader publication announcements would conceal or violate those boundaries.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 0e6b033d4bdb.

Labels

Label changes:

  • add P2: Repairs metadata hangs and misleading warnings during overlapping authentication publication, with a bounded affected surface and no established widespread outage.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The external-contributor proof gate does not apply to this maintainer PR, and no material authorization change triggers an exception. The captured body reports fresh and restarted compiled Gateway metadata/auth-refresh replays with successful RPCs and no refresh warnings; these runs were not independently executed here.

Label justifications:

  • P2: Repairs metadata hangs and misleading warnings during overlapping authentication publication, with a bounded affected surface and no established widespread outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The external-contributor proof gate does not apply to this maintainer PR, and no material authorization change triggers an exception. The captured body reports fresh and restarted compiled Gateway metadata/auth-refresh replays with successful RPCs and no refresh warnings; these runs were not independently executed here.

Evidence

What I checked:

  • Current main still has the failure mechanism: Current main unconditionally invalidates metadata on subordinate changes, clearing the recorded failure and creating a replacement wait. Both production files have identical blobs at the PR merge base and fetched main, so the proposed repair remains necessary. (src/gateway/server-chat-metadata-lifecycle.ts:63, 0e6b033d4bdb)
  • Publication owner explains the stranded wait: Authentication publication announces global readiness only when every configured owner is request-visible. A healthy agent can finish independently while a previously failed sibling prevents that announcement. These publication events and metadata generations are OpenClaw-owned; the introduced changes do not depend on a Codex runtime or protocol contract. (src/agents/prepared-model-runtime.ts:703, b701f4cd0fe6)
  • Refresh fencing preserves settlement and shutdown ownership: Invalidation advances the refresh version and detaches pending publication without discarding the replacement promise or tracked work. Version checks retire superseded preparation failures; current failures remain observable, and stop still joins outstanding work. (src/gateway/server-methods/chat-metadata-runtime.ts:409, b701f4cd0fe6)
  • Regression covers independent publications in their original order: The added composition test first settles a worker publication failure, then successfully publishes main-agent authentication without a global published event. It asserts that metadata retains the original failure and subsequently recovers after complete publication. The production lifecycle and prepared-owner publication compose here; underlying preparation is mocked. (src/gateway/server-chat-metadata-lifecycle.integration.test.ts:860, b701f4cd0fe6)
  • Caller, projection, and sibling coverage: The RPC handler delegates to the shared metadata runtime. Inspected coverage includes queued and building refreshes, initial attachment, repeated invalidation, shutdown, personal-account isolation, native-session overlays, and the Gateway RPC boundary. Existing draft-authority checks remain in the projection and response paths; no authorization-bearing value or access policy is introduced. (src/gateway/server-methods/chat-metadata-handler.ts:79, b701f4cd0fe6)
  • Captured validation and runtime evidence: The supplied PR body reports nine expected baseline failures, 88 passing candidate tests across seven suites, and compiled Gateway replays using a QA channel and loopback synthetic provider. Fresh and restarted candidate cases each produced two replies, five successful metadata RPCs, both models available, and zero refresh warnings. This is reported evidence from the captured body, not reviewer-executed validation; no linked raw runtime artifact was supplied. (b701f4cd0fe6)

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.

@steipete
steipete merged commit 707edba into main Sep 5, 2026
185 checks passed
@steipete
steipete deleted the codex/qa-metadata-refresh-lifecycle-20260905 branch September 5, 2026 16:12
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit to aniruddhaadak80/openclaw that referenced this pull request Sep 5, 2026
* origin/main: (46 commits)
  fix(gateway): keep chat metadata responsive across auth refresh (openclaw#139192)
  fix(doctor): keep Workshop relocation lint read-only (openclaw#139193)
  perf(ui): retain unchanged forwarded avatar publications (openclaw#139181)
  fix(config): guide exec policy migration repairs (openclaw#139143)
  test(i18n): refresh representative Watch key (openclaw#139197)
  fix(agents): preserve recovered scheduled-run outcomes (openclaw#139037)
  refactor(acp): simplify pending operation accounting (openclaw#139189)
  fix(plugin-sdk): harden account scope for pairing requests and challenges (openclaw#139142)
  perf(gateway): avoid redundant PR landing ancestry checks (openclaw#139186)
  perf(ui): release captured audio cache leases directly (openclaw#139174)
  fix(skills): validate names in library forms (openclaw#139184)
  fix(sessions): reduce cold catalog listing delays (openclaw#139146)
  perf(cron): scan preserved action output once (openclaw#139163)
  fix(agents): keep fresh tool results readable under context pressure (openclaw#139165)
  fix(compaction): heartbeat sessions ignore the active transcript byte cap (openclaw#136533)
  perf(agents): reuse snapshotted web search result rows (openclaw#139162)
  fix(onboarding): keep Tauri setup recoverable and verify model results (openclaw#139140)
  fix(memory): rank indexed sessions by source activity (openclaw#139112)
  perf(terminal): avoid rebuilding sanitized link fallbacks (openclaw#139159)
  perf(agents): bound retained tool result projection data (openclaw#139157)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 6, 2026
…claw#139192)

* fix(gateway): keep metadata reads settled during auth refresh

* test(gateway): normalize metadata lifecycle promise callbacks
necromman pushed a commit to necromman/openclaw that referenced this pull request Sep 20, 2026
…claw#139192)

* fix(gateway): keep metadata reads settled during auth refresh

* test(gateway): normalize metadata lifecycle promise callbacks

(cherry picked from commit 707edba)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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.

1 participant