Skip to content

refactor(gateway): simplify lifecycle mutation contracts - #110583

Merged
steipete merged 2 commits into
mainfrom
refactor/gateway-lifecycle-cleanup
Jul 18, 2026
Merged

steipete merged 2 commits into
mainfrom
refactor/gateway-lifecycle-cleanup

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

Post-landing cleanup of the gateway lifecycle surface from #110323 / #110497 — scar tissue from the start-stopped-delegating-to-restart evolution, plus contract tightening. No behavior change except one new warning.

  • Delete the impossible "scheduled" start outcome: every platform start() completes synchronously; the branch and its restart-worded response were fossils. start() contracts are now completed-only.
  • GatewayLifecycleMutationMode union replaces stringly-typed audit modes (29 literals now compile-checked); drop the never-supplied pid field; one shared best-effort mutation reporter (service-mutation.ts) so observer exceptions can never interrupt service control on any path.
  • Already-running start now surfaces previously discarded repair drift as a warning (text + JSON warnings[]) instead of silently swallowing it; still strictly idempotent — no repair, no restart.
  • Action-specific ServiceRecoveryResult types (start recovery can no longer claim "stopped").
  • Remove dead launchd handoff label/$5 plumbing.
  • Micro-dedup: cached TTY check in run.ts; forceFreePort() reuses killPids.

Proof

  • Focused suites green: daemon 298 passed, CLI 173, recovery/repair neighbors 75 — including daemon-cli.coverage and lifecycle-core.config-guard.
  • tsgo:core + tsgo:test:src green (Blacksmith Testbox); targeted oxlint clean; max-lines ratchet OK.
  • Structured review (Codex gpt-5.6-sol): clean, no actionable findings.

Release-note context: gateway start now warns when the already-running service's installed definition has drifted and needs gateway restart to apply.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime cli CLI command changes size: M maintainer Maintainer-authored PR labels Jul 18, 2026
@clawsweeper clawsweeper Bot added 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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 18, 2026
@clawsweeper

clawsweeper Bot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 18, 2026, 5:34 AM ET / 09:34 UTC.

Summary
The branch simplifies gateway lifecycle start and mutation-audit contracts, removes the obsolete scheduled-start result, and reports installed-definition drift when gateway start finds an already-running service.

PR surface: Source +31, Tests +43. Total +74 across 25 files.

Reproducibility: yes. in source, with medium confidence: configure a loaded and running gateway service whose installed command metadata has a version, port, or program-path mismatch, then run gateway start. The branch’s focused tests model this path, but no real environment result is attached.

Review metrics: 1 noteworthy metric.

  • User-visible warning surface: 1 conditional warning exposed in text and JSON. The branch changes the observable CLI contract only when an already-running service has installed-definition drift.

Stored data model
Persistent data-model change detected: migration/backfill/repair: src/cli/daemon-cli/lifecycle-core.test.ts, migration/backfill/repair: src/cli/daemon-cli/lifecycle-core.ts, migration/backfill/repair: src/cli/daemon-cli/start-repair.ts, migration/backfill/repair: src/daemon/service-types.ts, migration/backfill/repair: src/daemon/service.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add redacted terminal or live-output proof for an already-running, drifted installed service in normal and JSON modes.
  • Show in that proof that the command warns without repairing or restarting the service.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The body lists tests and static checks but supplies no after-fix real-service output for the new already-running repair-drift warning; add redacted terminal/live-output or runtime-log evidence showing normal and JSON behavior, then update the PR body for re-review.

Risk before merge

  • [P1] This intentionally turns a previously silent already-running repair-drift condition into CLI text output and a JSON warnings[] entry; direct behavior proof should confirm both representations and that no repair or restart occurs.

Maintainer options:

  1. Prove the output-contract change (recommended)
    Before merge, capture a redacted real run with an already-running service definition that has drifted, including normal output and --json output, and show that no restart or repair occurs.
  2. Accept the new warning contract
    A maintainer may accept the changed text and additive JSON warning behavior without further live evidence, explicitly owning compatibility for consumers that parse CLI output.

Next step before merge

  • [P1] No narrow automated repair is appropriate: contributor-supplied real behavior proof is missing, and the protected maintainer label requires a maintainer to review the intentional output-contract change.

Security
Cleared: The diff adds no dependency, workflow, permission, secret, artifact-download, or supply-chain execution surface; the new helper only isolates diagnostic observer failures.

Review details

Best possible solution:

Add redacted real-run evidence for an already-running gateway whose installed definition has drifted, showing the warning in normal and JSON output while confirming the service is neither repaired nor restarted.

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

Yes in source, with medium confidence: configure a loaded and running gateway service whose installed command metadata has a version, port, or program-path mismatch, then run gateway start. The branch’s focused tests model this path, but no real environment result is attached.

Is this the best way to solve the issue?

Yes, conditionally: preserving strict idempotence while surfacing actionable drift is narrower than repairing or restarting an already-running service. The remaining requirement is direct proof that the emitted text and JSON warning are useful and stable in a real service setup.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 75b1ac12df1e.

Label changes

Label changes:

  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.

Label justifications:

  • P3: This is a bounded gateway lifecycle cleanup with one low-frequency diagnostic-output change, not an active user-facing outage.
  • merge-risk: 🚨 compatibility: The PR changes previously silent gateway start behavior by emitting new text and an additive JSON warning for repair drift.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The body lists tests and static checks but supplies no after-fix real-service output for the new already-running repair-drift warning; add redacted terminal/live-output or runtime-log evidence showing normal and JSON behavior, then update the PR body for re-review.
Evidence reviewed

PR surface:

Source +31, Tests +43. Total +74 across 25 files.

View PR surface stats
Area Files Added Removed Net
Source 18 161 130 +31
Tests 7 69 26 +43
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 25 230 156 +74

What I checked:

  • Changed lifecycle contract: The branch changes the platform GatewayService.start() contract to complete with void, removes the scheduled start outcome, and returns repair issues with the already-running result so the CLI can expose drift without restarting the service. (src/daemon/service.ts:79, f39897e1782b)
  • New user-visible path: The start command adds a warning when an already-running service has repair issues, with text output for normal mode and warnings[] for JSON mode; the adjacent focused test covers the JSON warning shape. (src/cli/daemon-cli/lifecycle-core.ts:277, f39897e1782b)
  • Observer isolation: The new mutation reporter catches observer exceptions before they can interrupt authoritative service-control mutations, and the diff routes launchd, systemd, Scheduled Task, and CLI audit paths through it. (src/daemon/service-mutation.ts:1, f39897e1782b)
  • Prior merged lifecycle ownership: The preceding merged gateway lifecycle work established idempotent start and lifecycle auditing; this PR is a follow-up cleanup and warning path rather than a duplicate implementation. (src/daemon/service.ts:222, 6416baef8394)
  • Proof remains absent: The PR body reports focused tests and static checks, but it contains no after-fix terminal output, redacted runtime log, recording, or live-output artifact demonstrating an already-running installed service with drift and the resulting warning. (f39897e1782b)

Likely related people:

  • steipete: Authored the two immediately preceding merged gateway lifecycle changes and the current follow-up, including the idempotent-start and managed-start audit paths this refactor tightens. (role: recent area contributor; confidence: high; commits: 8992f92dab13, 6416baef8394, f39897e1782b; files: src/daemon/service.ts, src/cli/daemon-cli/lifecycle-core.ts, src/daemon/service-mutation.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (1 earlier review cycle)
  • reviewed 2026-07-18T09:13:02.606Z sha bcecd2e :: needs real behavior proof before merge. :: none

@steipete steipete self-assigned this Jul 18, 2026
@steipete
steipete force-pushed the refactor/gateway-lifecycle-cleanup branch from bcecd2e to f39897e Compare July 18, 2026 09:30
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jul 18, 2026
@steipete
steipete merged commit fab3cdf into main Jul 18, 2026
127 of 129 checks passed
@steipete
steipete deleted the refactor/gateway-lifecycle-cleanup branch July 18, 2026 10:09
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 19, 2026
…0583)

* refactor(gateway): simplify lifecycle mutation contracts

* refactor(cli): unexport internal emitDaemonActionMessage
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
…0583)

* refactor(gateway): simplify lifecycle mutation contracts

* refactor(cli): unexport internal emitDaemonActionMessage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M 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.

1 participant