Skip to content

fix(update): fence readiness credentials at transport send - #182343

Merged
steipete merged 9 commits into
mainfrom
codex/target-owned-update-readiness-20261023
Oct 24, 2026
Merged

steipete merged 9 commits into
mainfrom
codex/target-owned-update-readiness-20261023

Conversation

@steipete

@steipete steipete commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

An update can lose its executor lease while a readiness connection waits for authentication or a deferred request retry. The surrounding ownership checks reject the eventual result, but credentials or an authenticated request can already have been sent by then.

User Impact

Readiness probes stop sending when their update loses ownership. The transport checks the live owner immediately before socket creation and each RPC frame, including asynchronous authentication and startup retries. A refused send is not recorded as a successful connect send.

Why This Change Was Made

The existing probe passes its current owner assertion through the shared Gateway client. The check belongs at socket construction and socket.send, where no awaited work or host callback can invalidate it before transport I/O. Existing request retirement, connection errors, and proxy cleanup remain the lifecycle owners; no updater-specific policy is added to the shared client.

Post-hello dispatch preparation keeps its existing contract. Protocol-version changes continue to use the HTTP identity verification introduced in #182399, and authentication, pairing, configuration, and database schemas are unchanged.

Evidence

  • A real socket reproduction reassigned an isolated updater lease before releasing the Gateway challenge. Before the repair, a synthetic credential-bearing connect frame was sent; after the repair, the connection rejected with no credential frame.

  • The regression now enters through the real readiness probe, with the actual executor fence, to cover observer propagation and the transport boundary together. Allowed token/auth-none wire controls are retained, and the fixture exposes truthful startup identity for main's protocol-mismatch HTTP verification.

  • Package tests cover ownership loss during asynchronous token loading, revocation by the transport-registration callback with cleanup, and revocation between a correlated startup refusal and its retry.

  • Exact-main red→green: the consumer revoked-lease case sent a credential frame before the repair and no frame after it. Initial real-wire suite: 3/3 passed; the strengthened current/reassigned executor table then passed 2/2. Package authority and existing timing/close/reentrancy siblings: 11/11 passed, including synchronous refusal.

  • The final production delta is +54/-34 (net +20), reusing existing transport, request settlement and observer contracts. Duplicate error coercion and default-close policy are consolidated through their existing owners. Independent P0/P1 review found no actionable defects in the narrowed guard; the final owner simplification also passed independent P0/P1 review; Exact-head CI passed for 6b187d9c6b1885dd16080ef43430ef2e8bfb2aa6, including the authoritative PR gate.

  • Exact-CI-merge paired bundle proof passed without raising limits: chat boot gzip 1,275,549 bytes versus the 1,275,713-byte cap, down 59 bytes from its measured base. The final owner simplification passed 25 focused semantic tests plus canonical package type checking and owned declarations.

A bounded test-only correction also makes the scheduler-disabled multi-instance fixture use its already-allowed mock model and matching synthetic auth profile. CI exposed its previous explicit OpenAI override being rejected by the mock-only allowlist; scheduler assertions and the offline runner remain unchanged. The focused local E2E command could not prepare its runtime because this sparse checkout omits plugin asset sources, the corrected case then passed in exact 46f9 CI (19.119s; multi-instance file 3/3). Final-head CI passed on 6b187d9c6b1885dd16080ef43430ef2e8bfb2aa6.

An unchanged landscape question-footer case failed in Linux CI on 603c. An isolated replay and the original portrait→landscape pair passed locally, including a CI-matching Node worker, so the cause remains unresolved. Failure-only diagnostics now use the existing sanitized artifact owner around that exact assertion; successful interactions, taps, assertions and timeouts are unchanged. A temporary synthetic assertion failure exercised the new failure branch: it retained the original error and emitted only the intended fixed numeric/boolean scenario facts; the isolated proof checkout was restored byte-exact. This is diagnostic coverage, not a claimed UI repair.

The refreshed main baseline also exposed stale precompiled Gateway predicates: the existing optional expanded boolean was missing from six panel command variants. Canonical regeneration synchronizes that artifact with its unchanged schema (+12/−6 generated lines, separate from production LOC). Generation is byte-stable, its check passes, and 96 direct before/after assertions verify booleans become accepted while malformed values remain rejected. No protocol/schema/version change was made.

The socket fixture uses real protocol admission and authentication predicates with synthetic responses. It does not claim a full managed-service deployment or live-provider test.

Captured real-executor positive and negative proof

The following is actual canonical test output with only the local checkout path redacted. The current-lease case asserts exactly connect then health, a synthetic credential on the connect frame, and returned readiness/version/build. The reassigned-lease case asserts no received connect or health frames and the owner-loss error. Both enter confirmGatewayReachable with the actual executor assertion. The runner truncates long case names.

RUN  v5.0.5 <checkout>

 ↓ |infra| src/cli/daemon-cli/restart-health-protocol.test.ts > old/current local readiness control with none auth
 ↓ |infra| src/cli/daemon-cli/restart-health-protocol.test.ts > old/current local readiness control with token auth
 ✓ |infra| src/cli/daemon-cli/restart-health-protocol.test.ts > real executor readiness: current lease sends authenticated conne… 170ms
stderr | src/cli/daemon-cli/restart-health-protocol.test.ts > real executor readiness: reassigned lease sends no connect or he…
gateway connect failed: GatewayProtocolRequestError: UpdateCommandRecoveryPendingError: Update executor ownership is no longer current.

 ✓ |infra| src/cli/daemon-cli/restart-health-protocol.test.ts > real executor readiness: reassigned lease sends no connect or he… 101ms

 Test Files  1 passed (1)
      Tests  2 passed | 2 skipped (4)
   Start at  05:29:37
   Duration  17.78s (transform 73%, import 21%, setup 5%, tests 2%)

@clawsweeper

clawsweeper Bot commented Oct 24, 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 cli CLI command changes size: XL labels Oct 24, 2026
@steipete
steipete marked this pull request as ready for review October 24, 2026 07:06
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 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-24T14:21:42.220333Z 6b187d9 New commits
ℹ️ 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: 888f314cfc

ℹ️ 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 +358 to +360
const request: UpdateReadinessRequest = {
gatewayPort: params.gatewayPort,
timeoutMs: Math.max(1, remainingMs()),

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.

P1 Badge Preserve startup observations when delegated readiness times out

When a restarted Gateway remains in startup until the readiness budget expires, the child receives the parent's entire remaining budget but starts its own timer only after subprocess startup and imports. The parent deadline therefore expires before the child can return its final startup observation. Unlike the legacy path, this branch never updates the parent's health with intermediate observations, so the timeout handler returns the initial runtime.status: "unknown" snapshot without the running PID or startup phase. Consequently, gatewayReadinessPending() returns false and verification reports a hard failure instead of preserving the live Gateway as readiness-pending. Reserve time for child settlement and retain structured startup observations across the process boundary so slow startup preserves the existing best-effort update behavior.

AGENTS.md reference: AGENTS.md:L78-L78

Useful? React with 👍 / 👎.

@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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 24, 2026
@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR checks updater ownership immediately before Gateway transport I/O and restores generated panel validators to their existing schema contract.

Example: An updater lease is reassigned while its readiness socket awaits the Gateway challenge.

  • Before: The retired updater can send a credential-bearing connect frame.
  • After: The readiness probe rejects without sending connect or health frames.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with sufficient final-effect authority evidence and no actionable defects; proof uses a production-path socket harness rather than a full managed-service deployment.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): Captured output exercises confirmGatewayReachable through the actual executor fence and real WebSocket transport: current ownership sends authenticated connect plus health and returns identity, while reassignment before challenge release sends neither frame and reports owner loss.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An updater that has lost ownership can still send credentials or readiness requests after asynchronous connection preparation.
Reason: The maintainer-approved direction closes a reproduced authority gap with a small transport change and restores existing panel-schema acceptance.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored repair addresses a verified ownership gap, with no actionable findings on the reviewed head; exact-head CI remains pending.

Priority: P2
Reviewed head: 6b187d9c6b1885dd16080ef43430ef2e8bfb2aa6

Before merge

None.

Findings

None.

Agent review details

How this fits together

Update readiness passes its executor assertion through restart inspection and the Gateway client to WebSocket construction and frame sends.

flowchart LR
  A[Update executor lease] --> B[Readiness observer]
  B --> C[Restart health probe]
  C --> D[Gateway call client]
  D --> E[Transport authority check]
  E --> F[Gateway WebSocket]
Loading

Technical review

Best possible solution:

Retain the existing executor as authority owner and enforce its assertion at the shared transport boundary while keeping generated validators aligned with their schema.

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

Source and supplied base/head wire evidence establish that lease reassignment during challenge waiting previously allowed a credential frame and now rejects before sending it.

Is this the best way to solve the issue?

The repair uses the existing executor, transport, and request-settlement owners without adding updater policy to the protocol engine.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Shared Gateway protocol and request lifecycle keeps the original intent (7c9b8ba: Consolidate browser and Node protocol lifecycle while leaving transport-specific policy in adapters.)
  • Asynchronous device authentication keeps the original intent (74d61d4: Await host token operations and preserve accepted persistence across connection retirement.)
  • Restart readiness verification keeps the original intent (a5f3623: Reuse the established local control client and authentication contracts for restart verification.)
  • Generated panel validators keeps the original intent (f52fb07: Replace runtime compilation with generated predicates while preserving canonical schema acceptance.)
  • Scheduler-disabled fixture and footer diagnostics keeps the original intent (test(gateway): repair lifecycle acquisition fixtures #173481: Preserve real lifecycle assertions; the mock-provider correction retains offline scheduling, and footer diagnostics leave the existing failure assertion intact.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit a5f3623 adds src/cli/daemon-cli/restart-health-probe.ts:240 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a5f3623302fd; files: src/cli/daemon-cli/restart-health-probe.ts)
  • Vincent Koc: Raw commit 8c89d35 adds packages/gateway-client/src/client.ts:795 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 8c89d35a8ad8; files: packages/gateway-client/src/client.ts)

PR surface

Source +26, Tests +521, Docs +4. Total +551 across 18 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 10 66 40 +26
Tests 7 527 6 +521
Docs 1 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 18 597 46 +551

Review metrics

Metric Value Why it matters
Production versus test delta Production +54/-34; tests and test support +527/-6 The larger test delta exercises real executor reassignment and wire effects, asynchronous authentication, deferred retries, and retained readiness controls.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a focused updater ownership repair with a demonstrated transport failure and limited blast radius.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • 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.

History

Review history (4 earlier review cycles)
  • reviewed 2026-10-24T07:23:54.784Z sha 888f314 :: needs real behavior proof before merge. :: [P1] Preserve startup observations before the parent deadline expires | [P1] Keep retained service roots out of candidate child execution | [P2] Use a genuinely incompatible protocol in both regression fixtures | [P2] Migrate existing consumer fixtures to the negotiated readiness path
  • reviewed 2026-10-24T12:00:57.573Z sha 392b1d6 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-24T12:07:38.338Z sha 392b1d6 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-24T14:33:59.064Z sha 6b187d9 :: needs maintainer review before merge. :: none

Reviewed October 24, 2026, 10:40 AM ET / 14:40 UTC (Revision 5).

Carry the original readiness deadline into the target runtime and retain the
existing pending-recovery owner for incomplete or invalid observations. Keep
untouched predecessor readiness advisory, including when its older CLI lacks
the delegated observer, without restoring rollback authority.

Bound parent-owned recovery with the canonical deadline and retain completed
observation facts. Cover the no-original-service finalization boundary and
adapt legacy fixtures without weakening current target dispatch proof.

Derive the synthetic unsupported operator dialect from the current minimum;
CI's merge target restored protocol 4 while the branch base used protocol 5.
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime scripts Repository scripts labels Oct 24, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Oct 24, 2026
Keep the live executor assertion at socket construction and every authenticated frame, including deferred startup retries. Reuse canonical request settlement and record connect timing only after an actual send.

Refresh main and retire the private verifier handoff: #182399 already owns protocol-mismatch HTTP identity verification. Final focused proof: consumer 3/3 and package authority/timing/close siblings 11/11; independent P0/P1 review scoped-clean.
@steipete steipete changed the title fix(update): verify Gateway upgrades across protocol changes fix(update): fence readiness credentials at transport send Oct 24, 2026
Capture bounded sanitized question/composer/Details facts only after the existing assertion fails, reuse the canonical artifact owner, and rethrow the original error. Successful taps and assertions are unchanged. The Linux CI failure remains unexplained; isolated and original-order replays passed, and a synthetic failure proved diagnostic capture.
@openclaw-barnacle openclaw-barnacle Bot added the app: web-ui App: web-ui label Oct 24, 2026
Use canonical error coercion and phase admission, and share the private immutable default close decision. Preserve transport authority and onSent semantics while removing duplicate policy.

Exact CI-merge paired bundle proof passes at 1275549 bytes against the 1275713-byte chat cap; 25 focused semantic tests and canonical package types pass. No budget raised.
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The current head also synchronizes stale precompiled panel validators with the already-existing optional boolean expanded schema. Canonical generation/check is byte-stable, and 96 direct before/after assertions cover all six variants, valid booleans, omitted values, and invalid types; no schema or protocol version changed. This bounded runtime acceptance repair warrants a fresh review beyond the earlier transport findings.

The requested current/reassigned executor final-effect evidence is in the PR body: both controls enter the real readiness probe with the actual executor fence, and the captured sanitized output accompanies the assertions. Final independent review found no actionable P0/P1 defects; exact-head CI is running.

@clawsweeper

clawsweeper Bot commented Oct 24, 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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. 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. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 24, 2026
@steipete
steipete merged commit 7f919ca into main Oct 24, 2026
194 of 196 checks passed
@steipete
steipete deleted the codex/target-owned-update-readiness-20261023 branch October 24, 2026 14:52
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 25, 2026
…182343)

* fix(update): verify Gateway upgrades across protocol changes

* fix(update): retain pending recovery when readiness cannot settle

Carry the original readiness deadline into the target runtime and retain the
existing pending-recovery owner for incomplete or invalid observations. Keep
untouched predecessor readiness advisory, including when its older CLI lacks
the delegated observer, without restoring rollback authority.

Bound parent-owned recovery with the canonical deadline and retain completed
observation facts. Cover the no-original-service finalization boundary and
adapt legacy fixtures without weakening current target dispatch proof.

Derive the synthetic unsupported operator dialect from the current minimum;
CI's merge target restored protocol 4 while the branch base used protocol 5.

* fix(update): preserve serving ownership and fence readiness credentials

* test(gateway): align scheduler canary with mock model policy

Use the configured mock model and matching synthetic credential profile, retaining the disabled manager and offline scheduler assertions. The previous explicit OpenAI override failed its mock-only allowlist in CI.

* test(update): prove current and reassigned executor transport effects

Exercise both authority outcomes through the real readiness probe and executor fence. Assert connect/health and returned identity for current ownership, and zero frames after lease reassignment. Both focused cases passed; production is unchanged.

* test(ui): retain question footer expansion failure diagnostics

Capture bounded sanitized question/composer/Details facts only after the existing assertion fails, reuse the canonical artifact owner, and rethrow the original error. Successful taps and assertions are unchanged. The Linux CI failure remains unexplained; isolated and original-order replays passed, and a synthetic failure proved diagnostic capture.

* refactor(gateway): reuse error and connection failure policy

Use canonical error coercion and phase admission, and share the private immutable default close decision. Preserve transport authority and onSent semantics while removing duplicate policy.

Exact CI-merge paired bundle proof passes at 1275549 bytes against the 1275713-byte chat cap; 25 focused semantic tests and canonical package types pass. No budget raised.
RomneyDa added a commit that referenced this pull request Oct 31, 2026
* test(release): track pinned Codex version in hook pressure

Adapt main #184817 to the release fixture.

Co-authored-by: RomneyDa <[email protected]>

* test(release): give scheduler canary explicit auth

Adapt main #182343 to the release fixture.

Co-authored-by: RomneyDa <[email protected]>

* test(gateway): align scheduler canary fixture auth

Co-authored-by: RomneyDa <[email protected]>

---------

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

Labels

app: web-ui App: web-ui cli CLI command changes 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: L 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