Skip to content

fix(gateway): close TLS renewal with the gateway lifetime - #146504

Merged
steipete merged 1 commit into
mainfrom
steipete/ci-startup-finish-tls-renewal-stop
Sep 12, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/ci-startup-finish-tls-renewal-stop

Conversation

@steipete

@steipete steipete commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Refs #146275, #146267, #144587, #146246.

What Problem This Solves

Protects TLS-enabled Gateway shutdown from the registration mismatch that caused sidecar.stop is not a function and failed production typechecks. Current main contains the corrected registration; this PR adds the integrated startup-to-shutdown regression coverage.

User Impact

TLS-enabled Gateways can close cleanly and release certificate-renewal watches and pending work. This restores the intended lifecycle behavior without configuration, storage, or protocol changes. The installed updater is unchanged; a candidate Gateway uses the existing shutdown owner.

Why This Change Was Made

#146267 introduced TLS renewal with a complete stop() implementation. The subsequent sidecar ownership cutover in #146275 (ad08bd71ff1) changed registration from an array to variadic handles but missed this caller. Startup therefore registered the array itself as a sidecar.

Pass the existing renewal handle directly to the lifetime owner. The regression starts a real isolated TLS-enabled Gateway and verifies that shutdown completes and invokes the real renewal cleanup. Existing renewal tests cover joining pending reads, removing watches, and fencing stale publication.

Evidence

The reported check-prod-types job fails with the same TS2741 reproduced locally.

Before the production fix:

pnpm tsgo
server-startup-finish.ts(416,37): error TS2741: Property 'stop' is missing in type
'{ setEnabled: (next: boolean) => void; stop(): Promise<void>; }[]'
but required in type 'GatewayPostReadySidecarHandle'.

node scripts/run-vitest.mjs src/gateway/server-startup-lifetime.test.ts -t 'stops TLS renewal when the started Gateway closes'
shutdown step failed (gateway lifetime sidecars): sidecar.stop is not a function
shutdown step failed (late sidecar cleanup): sidecar.stop is not a function
Test Files 1 failed; Tests 1 failed | 13 skipped

After the fix:

  • pnpm tsgo: passed.
  • node scripts/run-vitest.mjs src/gateway/server-startup-lifetime.test.ts src/gateway/server-tls-renewal.test.ts src/gateway/server-lifetime-sidecars.test.ts --silent: 3 files, 22 tests passed (including the TLS shutdown regression).
  • node scripts/check-changed.mjs: passed. An initial lint finding in the test observer was fixed by binding the real cleanup method; the complete gate then passed.
  • git diff --check: passed.
  • Exact-head CI: run 34720340252 finished green for 9b4ad129b4935178f15abd30f3f7a9c7baef36e1; the repository watcher reported rollup=green, github_rollup=SUCCESS, and pending=0.

Full release/update validation, including a published-updater/candidate run, is outside this narrow CI repair lane. Lead Codex autoreview of the exact head is scoped-clean at P1. The landing worker independently verified the variadic registration owner and rechecked exact-head CI with the repository watcher (rollup=green, pending=0). No code from other contributors was adopted into this patch; related PRs are credited above as context.

ClawSweeper review

The completed review of 9b4ad129b4935178f15abd30f3f7a9c7baef36e1 found no actionable defects. No items needed fixes or skips. The integrated Gateway shutdown regression remains useful on current main. No code changed during landing preparation, so no re-review request was posted.

Pass the renewal handle directly to variadic sidecar registration after the ownership cutover in #146275. This restores production typechecks and clean TLS-enabled Gateway shutdown. Cover the real startup and close path with a regression.
@clawsweeper

clawsweeper Bot commented Sep 12, 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: S maintainer Maintainer-authored PR labels Sep 12, 2026
@steipete
steipete marked this pull request as ready for review September 12, 2026 21:34
@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 12, 2026
@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 12, 2026, 6:00 PM ET / 22:00 UTC (Revision 2).

ClawSweeper review

What this changes

Registers TLS certificate renewal directly with Gateway shutdown cleanup and adds a test that starts and closes a TLS-enabled Gateway.

Merge readiness

✅ Ready for maintainer review

No actionable defects found. The production correction already landed through #146412, but this PR retains meaningful regression coverage missing from main. Its maintainer ownership also precludes automatic closure.

Priority: P2
Reviewed head: 9b4ad129b4935178f15abd30f3f7a9c7baef36e1

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, correct repair with useful integration coverage and reported failing-before/passing-after validation.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its reported regression starts the production Gateway with real TLS material and observes real renewal cleanup; no tests were rerun during this read-only review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its reported regression starts the production Gateway with real TLS material and observes real renewal cleanup; no tests were rerun during this read-only review.
Evidence reviewed 9 items Introduced change: The pinned merge-base-to-head diff contains the direct renewal-handle registration and a startup/close regression. Unrelated base-branch changes are outside this PR's introduced delta.
Shutdown contract: The sidecar owner accepts variadic handles and invokes each handle's stop method; TLS renewal's existing stop implementation cancels its timer, removes file watches, and awaits pending work. Passing the handle directly satisfies that existing contract without adding another cleanup owner.
Meaningful remaining regression: The new test uses isolated state, real TLS material, the production Gateway startup entrypoint, and the real renewal cleanup with an observing wrapper. It asserts successful close and cleanup invocation. Existing renewal tests exercise the helper directly and cannot catch the incorrect startup registration.
Findings None None.
Security None None.

How this fits together

The Gateway watches its configured TLS certificate files and updates HTTPS listeners when valid replacement material arrives. Its shutdown owner must stop those watchers and join pending renewal work before releasing the server.

flowchart TD
  A[Configured certificate files] --> B[TLS renewal watcher]
  B --> C[HTTPS listeners]
  B --> D[Gateway lifetime owner]
  E[Gateway shutdown] --> D
  D --> F[Stop watches and join pending work]
  F --> G[Release server resources]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source 0, Tests +60. Total +60 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 1 1 0
Tests 1 60 0 +60
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 61 1 +60

Review metrics

None.

Root-cause cluster

Relationship: partial_overlap
Canonical: #146412
Summary: The merged canonical PR supplies the identical production correction; this PR additionally supplies startup-lifetime regression coverage.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Retain main's existing cleanup owner and add the startup-to-shutdown regression that protects its TLS registration boundary.

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

No current-main failure is established: main already contains the correction. The original array-registration failure is source-explained and documented by the submitted failing-before test output.

Is this the best way to solve the issue?

Yes. Direct registration uses the existing variadic cleanup contract, and the added test covers the real startup caller that helper-level tests missed.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 38d95fbbb457.

Labels

Label justifications:

  • P2: The PR protects TLS-enabled Gateway shutdown against a concrete registration regression; main already contains the production repair.
  • 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 maintainer-authored PR is exempt from the external-contributor proof gate. Its reported regression starts the production Gateway with real TLS material and observes real renewal cleanup; no tests were rerun during this read-only review.

Evidence

What I checked:

  • Introduced change: The pinned merge-base-to-head diff contains the direct renewal-handle registration and a startup/close regression. Unrelated base-branch changes are outside this PR's introduced delta. (src/gateway/server-startup-finish.ts:416, 9b4ad129b493)
  • Shutdown contract: The sidecar owner accepts variadic handles and invokes each handle's stop method; TLS renewal's existing stop implementation cancels its timer, removes file watches, and awaits pending work. Passing the handle directly satisfies that existing contract without adding another cleanup owner. (src/gateway/server-sidecar-owners.ts:13, 9b4ad129b493)
  • Meaningful remaining regression: The new test uses isolated state, real TLS material, the production Gateway startup entrypoint, and the real renewal cleanup with an observing wrapper. It asserts successful close and cleanup invocation. Existing renewal tests exercise the helper directly and cannot catch the incorrect startup registration. (src/gateway/server-startup-lifetime.test.ts:620, 9b4ad129b493)
  • Verified merge result: The test merge records the pinned base followed by the exact PR head as its parents. Comparing it with that base leaves only the added regression test; the production correction is already preserved by the base. (src/gateway/server-startup-lifetime.test.ts, 177470f80d60)
  • Merged production fix: GitHub confirms fix(gateway): register TLS renewal with sidecar owner #146412 merged as b405e7f at 2026-09-12T21:12:53Z. Its stated problem and one-line correction match this PR's production change. (b405e7f64410)
  • Current-main implementation: Fetched main already passes the renewal handle directly. Its startup-lifetime suite lacks this PR's successful TLS-close regression. (src/gateway/server-startup-finish.ts:416, 38d95fbbb457)

Likely related people:

  • Peter Steinberger: Raw commit e2c3eaa adds src/gateway/server-tls-renewal.ts:8 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e2c3eaadfc75; files: src/gateway/server-tls-renewal.ts)

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 (1 earlier review cycle)
  • reviewed 2026-09-12T21:46:15.597Z sha 9b4ad12 :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 92d6d74 into main Sep 12, 2026
181 checks passed
@steipete
steipete deleted the steipete/ci-startup-finish-tls-renewal-stop branch September 12, 2026 22:06
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 13, 2026
…46504)

Protect clean TLS-enabled Gateway shutdown by covering registration of certificate renewal with the Gateway lifetime owner through real startup and close.

openclaw#146267 added TLS renewal registration using an array; openclaw#146275 changed sidecar registration to variadic handles and missed that caller. Passing the renewal handle directly prevents failed production typechecks and shutdown errors (sidecar.stop is not a function). Current main already carries the one-line correction; this landing preserves the integrated regression that detects the caller-contract mismatch.

The test uses isolated synthetic TLS material, closes the real Gateway, and observes the real renewal cleanup. The recorded regression failed before the repair and passed afterward; focused sibling coverage passed 22 tests. Exact-head CI and lead Codex review passed. No configuration, storage, or protocol changes.

Refs openclaw#146267, openclaw#146275, openclaw#144587, openclaw#146246.
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: 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