Skip to content

fix(browser): prevent stale profile resurrection#104601

Merged
steipete merged 5 commits into
mainfrom
codex/fix-browser-profile-lifecycle
Jul 11, 2026
Merged

fix(browser): prevent stale profile resurrection#104601
steipete merged 5 commits into
mainfrom
codex/fix-browser-profile-lifecycle

Conversation

@steipete

@steipete steipete commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Closes #103784

AI-assisted; implementation and validation reviewed by the submitting maintainer.

What Problem This Solves

Fixes an issue where a browser start could finish after stop, reset, profile deletion, hot reload, or Gateway shutdown had already returned. That stale work could recreate browser state, retain an adapter, or leave an OpenClaw-managed child process behind.

Why This Change Was Made

Browser lifecycle ownership now lives in one per-profile actor: destructive transitions invalidate the current generation synchronously, cancel admitted work, and serialize exact-resource cleanup before later starts proceed. The refactor replaces the scattered promise and cleanup paths while preserving normal tab/action concurrency, managed-browser restart, remote CDP use, existing-session Chrome/Brave data, the extension relay, and attach-only browser ownership.

No browser config, Gateway protocol, storage shape, CLI flag, or plugin SDK surface changes. OpenClaw terminates only resources it owns; external browser processes are disconnected, never killed.

User Impact

Operators can stop, reset, delete, reconfigure, or shut down browser profiles without an earlier start resurrecting them afterward. Starting again after reversible stop/reset remains supported, and external or existing-session browsers stay alive.

Evidence

  • Current PR head: 1f3e30a1d25; runtime reviewed/tested head: d670d655ac0. Later commits remove a release-owned changelog line and keep test temp fixtures inside the browser plugin boundary on the preferred OpenClaw temp root; runtime bytes are unchanged.
  • Blacksmith Testbox focused browser/agent suites: 145 browser-extension files, 1,849 passed and 1 skipped; 29 agent/sandbox tests passed (1,878 passed total).
  • Blacksmith Testbox exact-patch changed gate: all four TypeScript lanes, core/plugin lint, database-first, sidecar-loader, media-helper, webhook, pairing, and runtime import-cycle guards passed with exit 0. Run: https://github.com/openclaw/openclaw/actions/runs/29161695258
  • Two fresh autoreview passes reported no actionable findings after the lifecycle refactor and again after cleanup/lint hardening.
  • Live isolated Dev Gateway with a real OpenAI gpt-5.4 agent:
    • Managed agent run ccc9c3e0-566f-4c10-bf60-eee571612d8e made two successful Browser calls and returned MANAGED_OK Example Domain.
    • Stop killed exact managed PID 42096 and closed CDP port 19235. A second agent run 78d15d64-a1e6-465f-9474-469aa6a18138 created PID 62612, made three successful Browser calls, and returned RESTART_OK Example Domains.
    • Gateway SIGINT completed in 147 ms, killed PID 62612, and closed its Gateway/CDP listeners.
    • Independently launched attach-only Chrome stayed alive and reachable throughout managed stop, restart, attach-only profile stop, and Gateway shutdown. Agent run 07956581-4790-4e15-bdbe-653e67eca28f made four successful Browser calls and returned EXTERNAL_OK Example Domain; the external process exited only during explicit validator cleanup.
    • Structured agent metadata reported provider openai, model gpt-5.4, fallbackUsed: false, and zero Browser-tool failures. Targeted validator-artifact scanning found no credential patterns.
  • Source-blind behavior contract: 7/8 clauses passed. The one failure is a pre-existing product-surface mismatch: the advertised reset-profile CLI is rejected by the Gateway's persistent-profile mutation boundary before this lifecycle code runs. Direct reset/race regression tests pass; the CLI boundary needs a separate trust-model decision and is not weakened here.

@steipete
steipete requested a review from a team as a code owner July 11, 2026 17:48
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Jul 11, 2026
@steipete

steipete commented Jul 11, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready test/proof record for current PR head 1f3e30a1d25 (runtime tree d670d655ac0; later commits only remove the release-owned changelog line and fix plugin-local test fixtures):

  • Blacksmith Testbox browser-extension suite: 145 files, 1,849 passed, 1 skipped. Focused agent/sandbox browser suite: 29 passed. Total: 1,878 passed.
  • Exact-patch pnpm check:changed on Blacksmith Testbox: all four TypeScript lanes, core and extension lint, database-first/sidecar/media/webhook/pairing guards, and runtime import-cycle checks passed with exit 0. Run: https://github.com/openclaw/openclaw/actions/runs/29161695258
  • Three fresh pre-land autoreviews after the lifecycle refactor, cleanup hardening, and plugin-local test-support fix: no actionable findings.
  • Exact-head PR CI: 57/57 jobs passed, including build, TypeScript, lint, browser tests, plugin boundaries, CodeQL, OpenGrep, and security guards. Run: https://github.com/openclaw/openclaw/actions/runs/29162617675
  • Current-head boundary probes passed: check-no-extension-test-core-imports across 2,391 extension files, and check-no-random-messaging-tmp using the preferred OpenClaw temp root.
  • Live isolated Dev Gateway, real OpenAI gpt-5.4, no embedded fallback:
    • run ccc9c3e0-566f-4c10-bf60-eee571612d8e: two successful Browser calls, MANAGED_OK Example Domain;
    • managed stop killed exact PID 42096 and closed CDP 19235;
    • run 78d15d64-a1e6-465f-9474-469aa6a18138: fresh PID 62612, three successful Browser calls, RESTART_OK Example Domains;
    • Gateway SIGINT completed in 147 ms, killed PID 62612, and closed Gateway/CDP listeners;
    • independently launched attach-only Chrome remained alive and reachable through managed stop/restart, attach-only profile stop, and Gateway shutdown; run 07956581-4790-4e15-bdbe-653e67eca28f made four successful Browser calls with zero failures. It exited only during explicit validator cleanup.
  • Targeted artifact scan found no OpenAI-key or 1Password-token patterns.

Source-blind behavior contract: 7 passed, 1 failed. The failure is a separate existing product-surface mismatch: the advertised reset-profile CLI is rejected by the Gateway persistent-profile mutation boundary before lifecycle code runs. Direct reset/race regression coverage is green; this PR deliberately does not weaken that trust boundary.

@clawsweeper

clawsweeper Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head a270b826b10be471b37bbafeb13f94079da9232d, but the PR head is now 1f3e30a1d258aa152603c62643aff820c6257ee7. Its old verdict and PR readiness labels are no longer current.

Next step
Run or wait for a fresh ClawSweeper review on the current PR head.

@steipete
steipete merged commit ea2b558 into main Jul 11, 2026
102 of 106 checks passed
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@steipete
steipete deleted the codex/fix-browser-profile-lifecycle branch July 11, 2026 18:06
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 12, 2026
* fix(browser): serialize profile lifecycle

* refactor(browser): tighten lifecycle cleanup

* chore(browser): keep release note in PR

* test(browser): keep temp fixtures inside plugin

* test(browser): use preferred temp root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Browser start can outlive stop, reset, delete, hot reload, and shutdown

1 participant