Skip to content

fix(gateway): stop TLS renewal through its lifetime owner - #146411

Closed
steipete wants to merge 1 commit into
mainfrom
codex/fix-tls-sidecar-registration
Closed

steipete wants to merge 1 commit into
mainfrom
codex/fix-tls-sidecar-registration

Conversation

@steipete

@steipete steipete commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Related: #146267 and #146275. Unblocks #146401.

What Problem This Solves

Fixes TLS renewal being registered as an array after the Gateway lifetime-sidecar owner changed to a variadic API.

User Impact

The lifetime owner receives the renewal handle itself, so shutdown can call its stop() method. This also repairs the main-branch TS2741 failure currently blocking type, lint, and package-boundary CI.

Why This Change Was Made

The TLS renewal caller landed alongside the sidecar ownership refactor and missed that API cutover. Pass the existing handle directly to its existing owner. Renewal policy, scheduling, and TLS configuration stay unchanged.

Evidence

The failing main integration is visible in the production type job: server-startup-finish.ts:416 passes an array where GatewayPostReadySidecarHandle is required. Source inspection confirms that the lifetime owner later calls .stop() on each registered handle.

The one-line repair passed independent P0–P2 review, exact-file formatting, and git diff --check. The existing exact-head CI compiler checks provide the regression guard; local dependency installation was unnecessary for this isolated repair. No new test duplicates the existing type contract.

After-change live proof passed through pnpm openclaw gateway run on built 30f1f01dfc2e, whose Gateway caller, TLS producer, and sidecar owner are byte-identical to this PR's 638a07d74dfba versions. The instance used private state/config/workspace/logging, credential-free environment, synthetic self-signed TLS, a free loopback port, and disabled channels/providers/cron/plugins.

HTTPS /healthz: 200, certificate verified, fingerprint matched
TLS renewal watchFile registrations: certificate + private key (1000 ms, nonpersistent)
SIGTERM: unwatchFile called with both original listeners
Native StatWatcher stop events: certificate + private key
Gateway shutdown: completed cleanly in 54 ms
Supported CLI wrapper: exit 0 in 382 ms after SIGTERM
Port reusable: yes; synthetic fixture removed: yes; forced kill: no

The observer recorded only the synthetic certificate/key watchers at Node's real watchFile/unwatchFile boundary. No production code was replaced or mocked. The exact-head CI production type check also passed: job103617942905. Four canceled test shards are being retried; there was no source/test failure in that attempt.

Pass the renewal handle directly to the variadic gateway lifetime owner. This completes the integration between TLS renewal (#146267) and the sidecar ownership refactor (#146275), repairing TS2741 and retaining working TLS watcher cleanup.
@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.

@clawsweeper

clawsweeper Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 12, 2026, 4:45 PM ET / 20:45 UTC.

ClawSweeper review

What this changes

Pass the TLS certificate-renewal handle directly to the Gateway lifecycle owner so shutdown can stop its watchers and join pending work.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR remains necessary: pinned main still passes an array to the variadic lifecycle owner. The focused correction has no actionable correctness findings and preserves the existing shutdown contract.

Priority: P2
Reviewed head: 638a07d74dfba257aa6fb238c46d1a91653bd742

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Recorded reviewer rating: A narrow, correct caller repair supported by the existing type contract and lifecycle coverage, with no identified merge defect. Real behavior proof remains required by host policy.
Proof confidence 🌊 off-meta tidepool Recorded reviewer rating; Required by policy: the recorded not-applicable assessment does not satisfy the current PR proof policy. Put relevant after-change evidence in the main PR body, then request a fresh review with @clawsweeper re-review. Recorded reviewer context: Verified repository-admin authorship exempts this PR from external-contributor proof. Source connects startup registration to watcher cleanup; no after-fix shutdown run was claimed or performed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Required by policy Required by policy: the recorded not-applicable assessment does not satisfy the current PR proof policy. Put relevant after-change evidence in the main PR body, then request a fresh review with @clawsweeper re-review. Recorded reviewer context: Verified repository-admin authorship exempts this PR from external-contributor proof. Source connects startup registration to watcher cleanup; no after-fix shutdown run was claimed or performed.
Evidence reviewed 8 items Introduced change and verified merge result: The merge-base-to-head patch changes only the renewal registration argument. The verified test merge has pinned main followed by the exact PR head as parents; its comparison against main contains the same correction. git diff --check passed.
Current main still needs the repair: Pinned main registers [tlsRenewal], while the lifecycle exposes the stop owner's variadic publish operation. An array becomes a registered entry without a stop method.
Cleanup contract: publish accepts individual handles, and stop invokes each handle's stop method. TLS renewal's stop method marks it stopped, invalidates pending observations, clears its timer, unregisters file watchers, and awaits pending work.
Findings None None.
Security None None.

How this fits together

The Gateway watches configured TLS certificate files and refreshes its HTTPS listeners when valid replacement material arrives. Its lifecycle owner collects background-service handles and stops them during shutdown.

flowchart TD
  A[Certificate files] --> B[TLS renewal watcher]
  B --> C[HTTPS listeners]
  B --> D[Renewal cleanup handle]
  D --> E[Gateway lifetime owner]
  F[Gateway shutdown] --> E
  E --> G[Stop watchers and join pending work]
Loading

Before merge

  • Add real behavior proof - Required by policy: the recorded not-applicable assessment does not satisfy the current PR proof policy. Put relevant after-change evidence in the main PR body, then request a fresh review with @clawsweeper re-review. Recorded reviewer context: Verified repository-admin authorship exempts this PR from external-contributor proof. Source connects startup registration to watcher cleanup; no after-fix shutdown run was claimed or performed.
Agent review details

Security

None.

PR surface

Source 0. Total 0 across 1 file.

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

Review metrics

None.

Root-cause cluster

Relationship: canonical
Canonical: #146411
Summary: This PR owns the focused TLS registration repair; the APFS work temporarily carries it as a prerequisite.

Members:

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

Technical review

Best possible solution:

Retain the existing variadic lifecycle owner and register the renewal handle directly, with no compatibility adapter or renewal-policy changes.

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

Yes, from source: TLS-enabled startup on pinned main registers an array, and shutdown invokes stop() on that array. Runtime reproduction and compiler execution were not performed in this read-only review.

Is this the best way to solve the issue?

Yes. Passing the existing handle directly repairs the violated type and cleanup contract at its caller without introducing another owner.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This repairs a bounded TLS shutdown integration defect on main without evidence of a shipped user outage.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit. This is the recorded reviewer rating; real behavior proof remains required by host policy.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Required by policy: the recorded not-applicable assessment does not satisfy the current PR proof policy. Put relevant after-change evidence in the main PR body, then request a fresh review with @clawsweeper re-review. Recorded reviewer context: Verified repository-admin authorship exempts this PR from external-contributor proof. Source connects startup registration to watcher cleanup; no after-fix shutdown run was claimed or performed.

Label justifications:

  • P2: This repairs a bounded TLS shutdown integration defect on main without evidence of a shipped user outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit. This is the recorded reviewer rating; real behavior proof remains required by host policy.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Required by policy: the recorded not-applicable assessment does not satisfy the current PR proof policy. Put relevant after-change evidence in the main PR body, then request a fresh review with @clawsweeper re-review. Recorded reviewer context: Verified repository-admin authorship exempts this PR from external-contributor proof. Source connects startup registration to watcher cleanup; no after-fix shutdown run was claimed or performed.

Evidence

What I checked:

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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

Copy link
Copy Markdown
Contributor Author

The canonical one-line repair landed through #146412 as b405e7f644106306d2d3965ecf22335fdbe15716. Verified GitHub merge state, commit ancestry on fetched main, and the corrected registerGatewayLifetimeSidecars(tlsRenewal) call. Closing this duplicate without reapplying the same change.

@steipete steipete closed this Sep 12, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Added actual supported-CLI TLS startup/shutdown evidence to the main PR body. HTTPS health passed with certificate verification, both real TLS renewal watchers were registered, SIGTERM removed both original listeners and emitted both native StatWatcher stop events, Gateway shutdown completed cleanly in 54 ms, and the CLI exited0 without a forced kill. The port was reusable and the isolated synthetic state/certificates/logging were removed. The tested Gateway caller, producer and lifetime owner are byte-identical to this PR head. The formerly failing production type check is also green.

@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper could not start a re-review for this item.

Reason: re-review requires an open issue or PR.

@steipete
steipete deleted the codex/fix-tls-sidecar-registration branch September 12, 2026 21:27
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 size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant