Skip to content

fix(gateway): preserve live owners through restart - #147242

Merged
steipete merged 5 commits into
mainfrom
steipete/upd-gateway-owner-identity
Sep 13, 2026
Merged

steipete merged 5 commits into
mainfrom
steipete/upd-gateway-owner-identity

Conversation

@steipete

@steipete steipete commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #140162
Related: #146387, #147019

What Problem This Solves

Fixes restarts killing a ready or slow-starting Gateway as stale, or failing when a foreground Gateway owns the port while an installed Scheduled Task uses a different launch mode.

User Impact

Verified live owners survive stale cleanup, including before their listener opens. Restart targets a recorded foreground owner even when a native service is installed. Scheduled Task cleanup preserves external supervisors and other tasks, and tells the operator which supervisor to use. Older installed-command-attributed Gateways remain terminable during an update.

Why This Change Was Made

The physical Gateway coordinator holds a separate SQLite database. A gateway-owner/global row in the existing shared state_leases table publishes PID, host, native start identity, listener mode, supervisor kind/name, and port. It reuses the existing heartbeat and dead/recycled-owner reclaim machinery. Supervisor identity is a JSON payload field on this new, unreleased row: no schema change, compatibility reader, configuration option, dependency, or retention change.

All round-three findings are addressed:

  • Native task authority requires the recorded schtasks kind and matching installed task name. External and other-task owners are preserved. Launchd/systemd do not select recorded owners by supervised mode; their shared stale cleanup already preserves recorded owners.
  • Publication retries the native self-identity lookup with the shared Windows budget. A remaining null stays unknown; heartbeat repairs it only for the current unexpired generation, matching PID/host, and a still-null stored identity. A good identity is never rewritten.
  • Unix cleanup captures group members and their native start identities before TERM. After the leader exits, escalation targets surviving matching members individually, retaining replacement-owner and PID-reuse protections.
  • Per the old-binary ruling, exact installed-argv attribution authorizes legacy cleanup even while a 2026.9.3/9.4 process holds the coordinator without a row. Both the full snapshot and fix: gateway stop/restart refuses a healthy gateway when the Windows process snapshot misses #146387 per-PID fallback already require exact argv plus port. Neither admits a port-only candidate. Without attribution, a held coordinator produces retry guidance and remains untouched.

Health checks no longer infer staleness from unknown listeners or the old startup timer. Foreground routing uses the caller's selected state. Ownership is rechecked before signals; failed heartbeat cleanup retains physical custody. The #146387 snapshot-miss handling and #147019 shared process-start budget remain intact.

Reported by @deYangar (#140162).

Evidence

  • Round-three regressions were run with the production fix hunks reversed. The targeted identity/group run failed 3 tests; Scheduled Task suites failed 6 and passed 47; run-loop publication failed 2. Failures showed permanent unknown identity, a surviving child, external/other-task owner selection, refused attributed old-binary cleanup, and missing unpublished-owner retry guidance. All pass with the fixes.
  • Focused suites: 566 passed, 2 existing skips, covering Gateway leases/locks, real heartbeat workers and generation guards, process groups, Scheduled Tasks, restart health, lifecycle, and run-loop behavior.
  • Both reporter CSV/CLI runs remain represented by fixtures: supervised ownership before port bind, and a ready foreground owner behind a supervised task definition. The September 13 report embeds its raw data inline; it contains no downloadable attachments.
  • Earlier isolated Mac live proof on 5eb21fa9f2bbb06b756f30251065d1b43823847a: pause after publication before listening, restart while paused, resume, verify new generation and /readyz 200 with no stale kill, then verify row/port cleanup.
  • pnpm check:changed: passed, including core/test typechecks, changed-file lint, schema v17 guard, and zero runtime import cycles. The final staged candidate received a P1 scoped-clean autoreview. Test-only type/lint findings were fixed without weakening assertions or baselines.
  • Initial round-three CI 34778815253 exposed 8 Windows Startup-fallback fixture failures: the test forced Linux platform detection on NTFS, causing the real coordinator to reject POSIX permissions. The follow-up uses native Windows ownership snapshots and taskkill state transitions, strengthens termination/refusal assertions, and keeps coordinator checks real. All 86 fixture tests, its scoped changed-file gate, and P1 review passed. On the final head, the Windows shard passed and its affected daemon batch improved from 8 failures/80 passes to 88 passes. Production code is unchanged. Final head: d4fdc0e13fe578a9a7b06db9dc89956c9210997c.
  • Final CI 34780366323 completed successfully on the exact final head. Actual checkout 77c87d9f6769928ee8841d418052efa981689b28 has parents main d2f67deda7908066cc111c794e1c6a0f5d0f82b7 and the exact final head. The main parent includes fix(ci): tooling shard fails on QA Profile Evidence routing after #143968 #147293; no empty refresh commit was needed.
  • Production LOC: this round +217/-24 (net +193); full PR +1024/-329 (net +695). The growth records supervisor authority, repairs unavailable identity through the existing heartbeat, and retains verified process-group members for escalation.

Native Windows final-effect proof was attempted through the local Parallels Windows 11 guest. It booted into unrepaired Windows startup recovery; bounded current-user exec returned 255. The guest was returned to its initial stopped state. Task-owned termination and external-owner refusal have boundary evidence, not native Windows execution. A published-updater end-to-end matrix remains unrun; no operator Gateway was used.

ClawSweeper review

Maintainer decision: land the reviewed head d4fdc0e13fe578a9a7b06db9dc89956c9210997c, accepting the bounded proof gaps below. The completed ClawSweeper review of this head reports no actionable code findings.

  • Resolved: src/cli/gateway-cli/run-loop.ts publishes supervisor kind; src/daemon/schtasks-process.ts selects only the installed task's recorded owners and preserves exact installed-argv cleanup for older holders without rows; src/infra/gateway-owner-lease.ts retries identity lookup and repairs unknown identity through the guarded heartbeat; src/infra/restart-stale-pids.ts retains captured group identities through escalation.
  • Skipped native Windows final-effect proof and its associated authority-risk item: the Parallels Windows guest is in startup recovery. The affected Windows CI batch passed 88 boundary tests, including native Windows snapshot/taskkill fixtures with real coordinator checks. This evidence is accepted for landing; actual Windows task-owned termination and forbidden-owner preservation remain a known live-proof gap.
  • Skipped data-model compatibility proof: supervisor kind is a JSON payload field on the new owner row introduced by this PR. No schema version, table, or retention change is introduced, and no shipped reader exists.
  • Resolved the ownerless installed-binary compatibility finding by preserving exact installed-argv-attributed termination, as on main. Unattributed coordinator holders remain untouched with retry guidance. The published-updater end-to-end matrix remains unrun; this bounded proof gap and the remaining proof/maintainer-decision checklist items are explicitly accepted for landing.

Record Gateway process identity and listener mode in the existing shared
state lease table while retaining the native coordinator as authority.
Revalidate ownership before stale cleanup and escalation, route foreground
restarts to the selected owner, and protect new startup generations from
stale observations left by an earlier crash.

Keep the published no-row discovery contract and the Windows snapshot-miss
fallback. Cover the reported lock-before-listener and foreground-task
mismatch flows with ordered regressions and shared SQLite lifetime proof.

Reported by @deYangar (#140162).
Fixes #140162
Related: #146387, #147019
@clawsweeper

clawsweeper Bot commented Sep 13, 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.

@steipete
steipete marked this pull request as ready for review September 13, 2026 17:50
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes size: XL maintainer Maintainer-authored PR labels Sep 13, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. 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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 13, 2026, 4:52 PM ET / 20:52 UTC (Revision 7).

ClawSweeper review

What this changes

The PR records Gateway process ownership so restart preserves live or slow-starting processes, targets foreground Gateways correctly, and limits Scheduled Task cleanup to verified owners.

Merge readiness

⛔ Blocked before merge - 5 items remain

The fix remains necessary, and no actionable code findings remain from this review. The recorded maintainer decision accepts the outstanding proof gaps; the supported proof override is not yet recorded in the PR labels.

Priority: P1
Reviewed head: d4fdc0e13fe578a9a7b06db9dc89956c9210997c

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The code repairs the prior findings and CI passes, while native authority and upgrade coverage remain bounded and explicitly accepted.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: Authority-chain proof required: Scheduled Task selection and revalidation reach mocked taskkill calls, without native allowed-owner termination and forbidden/reassigned-owner preservation results. The earlier macOS delayed-start recovery remains valid for its separate path. The maintainer explicitly accepts the remaining gap, but proof: override is absent. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: Authority-chain proof required: Scheduled Task selection and revalidation reach mocked taskkill calls, without native allowed-owner termination and forbidden/reassigned-owner preservation results. The earlier macOS delayed-start recovery remains valid for its separate path. The maintainer explicitly accepts the remaining gap, but proof: override is absent. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 8 items Current main still needs the fix: Fetched main still derives stale PIDs from service/runtime mismatch and fallback listener attribution. Its tree has no gateway-owner-lease.ts. The merged snapshot-recovery and activation-budget PRs address adjacent problems rather than this ownership publication change.
Scheduled Task authority repair: Selection requires a live process identity, matching port, schtasks supervisor kind, and installed task name. The current owner is reread before graceful termination and again before forced termination. External and other-task owners receive explicit refusal.
Earlier identity and escalation findings resolved: Publication retries the native start-identity lookup; heartbeat repair checks generation, PID, host, existing null identity, and unexpired ownership. Unix cleanup captures group members before TERM and revalidates their start identities before individual escalation.
Findings None None.
Security None None.

How this fits together

Gateway lifecycle commands coordinate running processes, native service managers, and shared SQLite state. Ownership checks determine which process may restart or stop, while health checks determine whether the replacement is ready.

flowchart TD
  A[Restart command] --> B[Read Gateway ownership]
  C[Gateway startup] --> D[Shared lease and physical coordinator]
  D --> B
  B --> E{Verified owner type}
  E --> F[Targeted foreground restart]
  E --> G[Native service restart]
  F --> H[Replacement health check]
  G --> H
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: Authority-chain proof required: Scheduled Task selection and revalidation reach mocked taskkill calls, without native allowed-owner termination and forbidden/reassigned-owner preservation results. The earlier macOS delayed-start recovery remains valid for its separate path. The maintainer explicitly accepts the remaining gap, but proof: override is absent. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - Native Windows task-owned termination and preservation of external, other-task, and reassigned owners remain unobserved; the maintainer explicitly accepted this gap.
  • Resolve merge risk (P1) - The published-updater-to-candidate matrix remains unrun. Unattributed coordinator holders are deliberately preserved with retry guidance, which can leave restart or update activation incomplete; this compatibility uncertainty is explicitly accepted.
  • Complete next step (P2) - Apply proof: override to record the maintainer's already documented acceptance of the remaining authority-proof gap.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +695, Tests +1568, Docs +1, Other -2. Total +2262 across 46 files.

View PR surface stats
Area Files Added Removed Net
Source 27 1024 329 +695
Tests 17 1764 196 +1568
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 2 -2
Total 46 2789 527 +2262

Review metrics

Metric Value Why it matters
Production versus test growth Production net +695 lines; tests and test support net +1,568 lines The stated production growth supports ownership publication, guarded heartbeat repair, and process-group escalation within existing lifecycle owners.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/infra/gateway-owner-lease.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #140162
Summary: This PR is the explicit candidate fix for the reported restart ownership failures; the merged related changes provide complementary behavior.

Members:

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

Merge-risk options

Maintainer options:

  1. Record the already accepted proof exception (recommended)
    Apply proof: override to formalize the maintainer's recorded acceptance of the Windows authority and updater proof gaps.

Technical review

Best possible solution:

Keep ownership publication with the existing lease/coordinator lifecycle, preserve legacy installed-argument attribution, and retain the documented upgrade-risk acceptance.

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

Yes, source inspection supports the reported mechanism: current main can classify a listener as stale from native-runtime mismatch without consulting the proposed owner record. This review did not execute a current-main reproduction.

Is this the best way to solve the issue?

Yes, the patch uses the existing coordinator, lease heartbeat, and targeted restart contracts, and the earlier defects are repaired. Native Windows and published-updater coverage remain limited as explicitly acknowledged.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The linked report demonstrates restart killing ready or slow-starting Gateways and leaving Windows users without a running service.
  • merge-risk: 🚨 compatibility: Restart and update cleanup behavior changes for existing installations without recorded ownership, and the published-updater matrix remains unrun.
  • merge-risk: 🚨 security-boundary: Persisted supervisor identity now selects termination targets, while native forbidden-owner and reassignment proof remains an accepted coverage gap.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: Authority-chain proof required: Scheduled Task selection and revalidation reach mocked taskkill calls, without native allowed-owner termination and forbidden/reassigned-owner preservation results. The earlier macOS delayed-start recovery remains valid for its separate path. The maintainer explicitly accepts the remaining gap, but proof: override is absent. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Current main still needs the fix: Fetched main still derives stale PIDs from service/runtime mismatch and fallback listener attribution. Its tree has no gateway-owner-lease.ts. The merged snapshot-recovery and activation-budget PRs address adjacent problems rather than this ownership publication change. (src/cli/daemon-cli/restart-health.ts:245, 6dbdbc515515)
  • Scheduled Task authority repair: Selection requires a live process identity, matching port, schtasks supervisor kind, and installed task name. The current owner is reread before graceful termination and again before forced termination. External and other-task owners receive explicit refusal. (src/daemon/schtasks-process.ts:183, d4fdc0e13fe5)
  • Earlier identity and escalation findings resolved: Publication retries the native start-identity lookup; heartbeat repair checks generation, PID, host, existing null identity, and unexpired ownership. Unix cleanup captures group members before TERM and revalidates their start identities before individual escalation. (src/infra/gateway-owner-lease.ts:130, d4fdc0e13fe5)
  • Authority tests and their boundary: The Scheduled Task tests cover external/other-task refusal and owner replacement before graceful and forced termination. Their process snapshots, lease reads, and taskkill execution are mocked; they establish boundary behavior rather than native Windows final effects. (src/daemon/schtasks.stop.test.ts:619, d4fdc0e13fe5)
  • Recorded maintainer disposition: The supplied body snapshot, sourceRevision fe57b01b2488d90a6866897b20ce7d6d982cde6520f072b2d0a3053de75c0d7f, explicitly accepts native Windows authority-proof and published-updater gaps for this head. A live read retained that disposition and showed no proof: override label. The author has verified repository admin permission. This resolves the human choice without establishing the missing runtime observations. (d4fdc0e13fe5)
  • Existing release compatibility retained: The v2026.9.4 source selects Windows processes using installed arguments and port. This PR preserves that legacy attribution when no owner row exists, including the merged per-PID fallback from fix: gateway stop/restart refuses a healthy gateway when the Windows process snapshot misses #146387. Local release-blob inspection failed, so the release source was read successfully through GitHub. (src/daemon/schtasks-process.ts:160, 3a9d69db306c)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • fszcd: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record the accepted proof waiver with proof: override; another implementation change or repeated maintainer decision is unnecessary.

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 (6 earlier review cycles)
  • reviewed 2026-09-13T18:05:35.424Z sha 19973e7 :: needs real behavior proof before merge. :: [P1] Preserve external supervision when selecting Scheduled Task owners | [P1] Recover a failed start-identity lookup before freezing the owner record | [P2] Retain the verified process-group target through escalation
  • reviewed 2026-09-13T18:23:06.254Z sha 5eb21fa :: needs real behavior proof before merge. :: [P1] Preserve external supervision when selecting Scheduled Task owners | [P1] Recover a failed start-identity lookup before freezing the owner record | [P2] Retain the verified process-group target through escalation
  • reviewed 2026-09-13T18:59:34.413Z sha 2a430d4 :: needs real behavior proof before merge. :: [P1] Preserve external supervision when selecting Scheduled Task owners | [P1] Recover a failed start-identity lookup before freezing the owner record | [P2] Retain the verified process-group target through escalation
  • reviewed 2026-09-13T19:19:22.278Z sha 2a430d4 :: needs real behavior proof before merge. :: [P1] [P1] Preserve external supervision when selecting Scheduled Task owners | [P1] [P1] Recover a failed start-identity lookup before freezing the owner record | [P2] [P2] Retain the verified process-group target through escalation
  • reviewed 2026-09-13T19:58:36.505Z sha 2729ef0 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-13T20:28:03.433Z sha d4fdc0e :: needs real behavior proof before merge. :: none

Use the installed service environment for ownership reads during native
restart and stop. Extend the stored-environment regression and update
cleanup assertions to cover the selected state directory.

Refs #140162
Acquire non-reentrant physical Gateway exclusion before legacy Windows
termination, and retain it through graceful cleanup, escalation, and exit
verification. Missing lease rows cannot authorize killing an unpublished
coordinator holder.

Preserve ambiguous coordinator-backed owners and keep file-lock-only legacy
cleanup while physical ownership is free. Cover the publication ordering and
prevent replacement admission until termination has settled.

Refs #140162
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Sep 13, 2026
@steipete
steipete merged commit 5469328 into main Sep 13, 2026
202 of 203 checks passed
@steipete
steipete deleted the steipete/upd-gateway-owner-identity branch September 13, 2026 20:55
@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 14, 2026
Record Gateway owner identity alongside the physical lifecycle coordinator so restart cleanup preserves live and slow-starting Gateways before they begin listening. Route foreground restarts through the recorded owner even when an installed Scheduled Task uses a different launch mode.

Limit Scheduled Task termination to the installed task's recorded owners or exact installed-argv-attributed legacy processes. Revalidate ownership before termination, repair initially unavailable native process identity through the guarded heartbeat, and preserve captured Unix process-group identities through escalation.

Validated by exact-head CI run 34780366323, including the affected Windows batch's 88 passing tests, and a scoped-clean P1 review. Native Windows final-effect proof and a published-updater end-to-end matrix remain accepted proof gaps; the Windows guest was unavailable in startup recovery. Supervisor metadata uses the new owner row's JSON payload without a schema version, table, or retention change.

Reported by @deYangar (openclaw#140162).
Fixes openclaw#140162
NEXTAltair added a commit to NEXTAltair/openclaw that referenced this pull request Sep 24, 2026
rebase 時のコンフリクト解決 (onto 92635da, 元コミット 119f95fdaa6):
- 上流 openclaw#143905/openclaw#147242 で safe RPC restart 分岐に
  assertGatewayServiceFallbackAllowed("safe RPC restart") が追加された。
  本コミットは safe 分岐を external-supervisor 判定より前へ移し暗黙 safe 判定を
  足しているため、移動先の分岐に上流のガードを取り込み、旧位置の重複分岐は削除
NEXTAltair added a commit to NEXTAltair/openclaw that referenced this pull request Nov 10, 2026
rebase 時のコンフリクト解決 (onto 92635da, 元コミット 119f95fdaa6):
- 上流 openclaw#143905/openclaw#147242 で safe RPC restart 分岐に
  assertGatewayServiceFallbackAllowed("safe RPC restart") が追加された。
  本コミットは safe 分岐を external-supervisor 判定より前へ移し暗黙 safe 判定を
  足しているため、移動先の分岐に上流のガードを取り込み、旧位置の重複分岐は削除

rebase 時のコンフリクト解決 (onto 57fd13e, 元コミット 21f40bf994c):
- 上流 8b680f3 (openclaw#178163) が createSafeGatewayRestartPreflight の
  inspectors 引数と SafeRestartInspectors 型を削除。引数なしの形に合わせ、
  session admission / mutation を 0 に固定するスタブだけを外して実数で数える
- 上流 c268b9d (openclaw#181608) が SafeRestartTarget 型を引数へインライン化。
  インライン型のまま transport 引数を追加
- 上流がテストを describe なしのトップレベル it と、実モジュールの spy による
  カウンタ差し替えに書き直したため、両テストファイルは上流版を基に
  本コミットのケースを追加。restart-coordinator.test.ts は
  session-controller.lifecycle.js を spy して admitted turn を 1 件にする

rebase 時の調整 (onto 258d034, 元コミット 76c4af4b6cc):
- restart-suspension.test.ts: 上流 36e277d (openclaw#175837) が
  session-lifecycle-admission.js を session controller へ統合して削除し、
  上流 f27df1d (openclaw#165330) が scheduleGatewayRestart の skipCooldown を
  削除していた。どちらも前回のベース (57fd13e) より前の変更で、
  このファイルは読み込みに失敗し上流分を含む全テストが動いていなかった。
  後継の beginSessionEffect / getSessionControllerWorkCount
  (session-controller.lifecycle.js) へ置き換え、skipCooldown を外した。
  クールダウンは直前に再起動を発信した場合だけ掛かるため、外しても挙動は同じ

rebase 時のコンフリクト解決 (onto 638a185, 元コミット a06162363f5):
- 上流が lifecycle-safe-restart.ts に restartFlagConflictError / assertNativeRestartFlags
  を追加し、runDaemonRestart の冒頭で呼ぶ形にした (--preserve-definition と --safe、
  --skip-deferral の組み合わせ検査)。上流の2関数と呼び出しを残したまま
  shouldUseImplicitSafeRestart と requestSafeGatewayRestartIfNeeded の呼び出しを
  その直後に並べた (フラグ検査 → 暗黙 safe 判定 → external-supervisor の順)。
  旧位置の `if (opts.safe)` 分岐は本コミットが既に削除済みで、重複は残っていない。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR 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. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: gateway restart kills ready/slow-booting gateway as "stale process" after 181s timeout, and never finds manually-started foreground gateways

1 participant