Skip to content

refactor(macos): move PortGuardian state to SQLite - #110527

Merged
steipete merged 9 commits into
mainfrom
codex/sqlite-port-guardian
Jul 18, 2026
Merged

steipete merged 9 commits into
mainfrom
codex/sqlite-port-guardian

Conversation

@steipete

@steipete steipete commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

#110392 landed as prerequisite commit 98410d986eee7ce7cff8e8466c6d5f9314ae784b; this PR now targets main.

What Problem This Solves

The macOS PortGuardian orphan-tunnel ledger remains in a host-global JSON file even though OpenClaw already ships a canonical SQLite table for the same durable records. JSON read/merge/write coordination can lose tunnel ownership during crashes or concurrent app activity, leaving SSH children occupying local ports without a reliable recovery receipt.

Why This Change Was Made

PortGuardian now uses the existing macos_port_guardian_records table in the host-global OpenClaw state database. The logical record shape remains unchanged: pid, port, command, mode, and timestamp. This is additive at the schema and API boundaries: no table change, schema-version bump, wire-format change, or dual-write path.

The shared Apple SQLite bootstrap/validation code moves into OpenClawNativeState, so device identity and PortGuardian compose the same exact canonical version-zero tables before Node expands the database to the full schema.

Legacy port-guard.json is a one-time migration input only. Migration snapshots under the shipped Darwin lock, plans process reconciliation outside both the file lock and SQLite transaction, revalidates the exact source, applies a short synchronous transaction, verifies receipts, and retires the JSON file. Runtime then reads and writes SQLite only.

Mixed-version app copies fail closed. A signed storage-capability marker is accepted only when Security.framework metadata matches the running process kernel CDHash. Tunnel launch holds a guardian reservation from completed legacy reconciliation through process spawn and durable receipt commit. Every mutation transaction revalidates the supported schema and canonical table, including retained connections after another process advances the database.

User Impact

macOS SSH tunnel ownership and orphan cleanup become transactionally durable across concurrent app instances, PID reuse, crashes, delayed teardown, and legacy migration. Fresh installs no longer create the JSON ledger or lock sidecar.

This is a one-way storage cutover. Downgrading afterward to an older JSON-only app does not expose receipts written only to SQLite; rollback requires restoring a compatible backup or upgrading again.

Maintainer Decision

Accepted by the maintainer's explicit land all instruction:

  1. Native-runtime migration, bounded to interoperability with the shipped Darwin lock and signed mixed-copy detection.
  2. One-way downgrade/mixed-version behavior: old JSON-only copies must not share the migrated state directory.

Evidence

  • Exact head: bd1fc1eb3b93c55cc5d8269ecb0438454cafb449, targeting main after refactor(state): move device identity into canonical SQLite state #110392 landed. git range-diff proves all 9 PortGuardian commits patch-identical to prior fully reviewed head d4889f49d1dbdb8e9a4f7bc440f81b7387696f7a.
  • Developer-ID-signed candidate proof on the patch-equivalent pre-restack head: released v2026.7.1 had no storage marker; mixed-version exclusion preserved JSON and the live SSH child; one-time migration preserved one exact SQLite receipt; restart was idempotent; orphan recovery killed the child and compare-deleted its receipt. The guest ended SIGNED_PORTGUARDIAN_PROOF=PASS, then snapshot restore stopped the VM.
  • Current-head TypeScript proof: 87 state-database tests passed with 1 skip, 490 database-first guard tests passed, and 46 device-identity/migration tests passed.
  • Final PortGuardian store proof: 21 Swift tests passed, including retained-connection rejection after a newer schema appears. Earlier signed-app scope passed 47 PortGuardian/tunnel tests.
  • Current exact-head hosted CI is green: 90 passed checks, 29 intentional skips, and no failure or pending check. Capacity-only queued native lanes were rerun as attempt 2; macos-swift, ios-build, and openclaw/ci-gate all passed in run 29652606607.
  • Full architecture chain, Kysely guardrails, dead-code exports, iOS SwiftFormat, generated baseline, and diff checks pass on the final stack. The final head also passes a focused OpenClawKit target build and exact SwiftFormat check.
  • Fresh autoreview of the final PortGuardian test-caller cleanup: clean, no accepted/actionable findings, confidence 0.95. The preceding identity caller cleanup was clean at 0.99, PortGuardian tree-delta review at 0.98, stale-schema hardening at 0.96, and identity error-type cleanup at 0.97.

AI assistance was used for implementation and review. Maintainer-directed design, focused tests, signed native behavior proof, and patch-identity checks were performed before handoff.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: ios App: ios app: macos App: macos scripts Repository scripts size: XL maintainer Maintainer-authored PR labels Jul 18, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. 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. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. 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, 12:47 PM ET / 16:47 UTC.

Summary
The branch moves macOS PortGuardian’s host-global SSH-tunnel ledger from port-guard.json to the existing macos_port_guardian_records SQLite table, including legacy migration, native bootstrap sharing, and mixed-version safeguards.

PR surface: Tests +54, Docs +10, Other +2109. Total +2173 across 24 files.

Reproducibility: no. high-confidence live reproduction was independently established in this read-only review. The current JSON read/merge/write ownership path and the proposed crash/concurrency failure mode are clear from the supplied source context, but no current-main failure scenario was run.

Review metrics: 1 noteworthy metric.

  • Persistent-state owners: 1 JSON ledger retired; 1 existing SQLite table adopted. This changes the macOS upgrade and downgrade behavior for host-global SSH tunnel recovery, so proof must cover existing installations as well as fresh state.

Stored data model
Persistent data-model change detected: database schema: apps/shared/OpenClawKit/Sources/OpenClawKit/DeviceIdentitySQLiteStore.swift, database schema: apps/shared/OpenClawKit/Tests/OpenClawKitTests/NativeStateBootstrapTests.swift, database schema: apps/shared/OpenClawKit/Tests/OpenClawNativeStateTests/OpenClawNativeStateSQLiteTests.swift, database schema: docs/refactor/database-first.md, database schema: src/state/openclaw-state-db.test.ts, migration/backfill/repair: docs/refactor/database-first.md, and 2 more. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🐚 platinum hermit
Result: blocked until stronger 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:

  • Attach a redacted, inspectable current-head signed native transcript or artifact covering migration, mixed-copy exclusion, restart, and orphan cleanup.
  • Obtain explicit maintainer acceptance of the one-way downgrade and mixed-version storage contract.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The PR describes prior signed native testing, but no redacted inspectable artifact demonstrates the migration and recovery path on current head; attach terminal output, logs, recording, or a linked artifact and redact private paths, endpoints, and credentials. 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.

Risk before merge

  • [P1] Existing users who downgrade to a JSON-only build, or run an old app copy against the migrated state directory, cannot observe SQLite-only tunnel receipts; that intentional compatibility boundary needs explicit release-owner acceptance.
  • [P1] The supplied proof narrative does not include an inspectable final-head artifact demonstrating migration, mixed-copy exclusion, restart, and orphan recovery on a signed native build.

Maintainer options:

  1. Attach final-head native proof and approve the cutover (recommended)
    Before merge, attach redacted inspectable evidence from the current head covering legacy migration, an older-copy exclusion attempt, restart idempotence, and orphan recovery, then explicitly accept the one-way upgrade contract.
  2. Choose a supported rollback policy
    If JSON-only downgrade or old-copy coexistence must remain supported, pause this PR and redesign the migration contract rather than merging the current fail-closed cutover.

Next step before merge

  • [P1] The remaining blockers are a maintainer-owned persistent-state policy choice and contributor-supplied inspectable native proof, not a narrow mechanical repair.

Maintainer decision needed

  • Question: Should OpenClaw support the proposed one-way PortGuardian storage cutover, including fail-closed coexistence with older JSON-writing macOS app copies and no JSON-only downgrade path?
  • Rationale: This changes the persistent-state and upgrade contract for host-global SSH tunnel recovery; source review cannot decide the supported downgrade and mixed-version policy on behalf of release owners.
  • Likely owner: steipete — They are the strongest identified owner of the merged adjacent native-state work and this PortGuardian migration design.
  • Options:
    • Approve the SQLite-only cutover (recommended): Accept the documented one-way upgrade contract after final-head signed migration, mixed-copy, restart, and orphan-recovery proof is attached.
    • Require a different upgrade contract: Keep this PR open while maintainers define a supported migration or downgrade path before the JSON ledger is retired.

Security
Cleared: No concrete security or supply-chain regression was identified in the reviewed native storage and build-surface changes; the signed mixed-copy boundary remains a maintainer-approved merge risk.

Review details

Best possible solution:

Land one canonical SQLite-only PortGuardian owner only after a maintainer accepts the one-way downgrade/mixed-version contract and the PR contains redacted, inspectable final-head native evidence for migration and orphan recovery.

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

No high-confidence live reproduction was independently established in this read-only review. The current JSON read/merge/write ownership path and the proposed crash/concurrency failure mode are clear from the supplied source context, but no current-main failure scenario was run.

Is this the best way to solve the issue?

Unclear until maintainers accept the upgrade contract: using the existing canonical SQLite table is the maintainable direction, but retiring a host-global JSON ledger requires final-head native proof and an explicit downgrade/mixed-version policy.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This is a substantial but bounded macOS storage refactor with explicit upgrade consequences, not evidence of an active emergency.
  • merge-risk: 🚨 compatibility: The branch retires the JSON ledger and intentionally leaves JSON-only downgrade and old-copy coexistence unsupported after migration.
  • merge-risk: 🚨 security-boundary: Mixed-version detection and the storage-capability marker use code-signing metadata to decide whether another app copy may share the state directory.
  • merge-risk: 🚨 availability: The ledger controls orphan SSH tunnel cleanup, so an incorrect migration or retained-connection check can leave ports occupied or terminate the wrong child.
  • 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 stronger real behavior proof before merge: The PR describes prior signed native testing, but no redacted inspectable artifact demonstrates the migration and recovery path on current head; attach terminal output, logs, recording, or a linked artifact and redact private paths, endpoints, and credentials. 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

PR surface:

Tests +54, Docs +10, Other +2109. Total +2173 across 24 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 54 0 +54
Docs 1 11 1 +10
Config 0 0 0 0
Generated 0 0 0 0
Other 21 2643 534 +2109
Total 24 2708 535 +2173

What I checked:

Likely related people:

  • steipete: Authored the merged adjacent device-identity SQLite migration and the current nine-commit PortGuardian migration stack, making them the strongest feature-history routing candidate. (role: recent native-state and PortGuardian contributor; confidence: high; commits: 84536b7d6e24, 125daf9de055, 58106aefec04; files: apps/shared/OpenClawKit/Sources/OpenClawNativeState/OpenClawNativeStateSQLite.swift, apps/macos/Sources/OpenClaw/PortGuardian.swift, apps/macos/Sources/OpenClaw/PortGuardianRecordStore.swift)
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 (12 earlier review cycles; latest 8 shown)
  • reviewed 2026-07-18T12:37:42.816Z sha 41e3e75 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-18T12:52:11.319Z sha d89359e464d0aa8ae074f06361caa99f118d5db7 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-18T13:55:18.679Z sha d0d37d3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-18T14:25:11.308Z sha d15e20d :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-18T14:39:14.158Z sha 2620ff02dda519dbcd9be1f1fdb7506d0437bc81 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-18T14:55:01.542Z sha d4889f4 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-18T15:18:46.087Z sha d4889f4 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-18T16:00:55.413Z sha d4889f4 :: needs real behavior proof before merge. :: none

@steipete
steipete force-pushed the codex/sqlite-device-identity branch from c1f0e62 to 36219f8 Compare July 18, 2026 08:11
@steipete
steipete requested a review from a team as a code owner July 18, 2026 08:11
@steipete
steipete force-pushed the codex/sqlite-port-guardian branch from a6b74d8 to 7fd9b3a Compare July 18, 2026 08:21
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 18, 2026
@steipete steipete self-assigned this Jul 18, 2026
@steipete
steipete force-pushed the codex/sqlite-device-identity branch from 36219f8 to 4328e27 Compare July 18, 2026 09:09
@steipete
steipete force-pushed the codex/sqlite-port-guardian branch from 7fd9b3a to 0fa7512 Compare July 18, 2026 09:25
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 18, 2026
@steipete
steipete force-pushed the codex/sqlite-device-identity branch from 4328e27 to d7c329c Compare July 18, 2026 12:33
@steipete
steipete force-pushed the codex/sqlite-port-guardian branch from 0fa7512 to 41e3e75 Compare July 18, 2026 12:34
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime cli CLI command changes commands Command implementations agents Agent runtime and tooling plugin: file-transfer labels Jul 18, 2026
@steipete
steipete force-pushed the codex/sqlite-port-guardian branch from d4889f4 to bd1fc1e Compare July 18, 2026 16:45
@openclaw-barnacle openclaw-barnacle Bot removed gateway Gateway runtime cli CLI command changes commands Command implementations agents Agent runtime and tooling plugin: file-transfer labels Jul 18, 2026
@steipete
steipete merged commit 4d27b5b into main Jul 18, 2026
198 of 206 checks passed
@steipete
steipete deleted the codex/sqlite-port-guardian branch July 18, 2026 17:15
@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
* refactor: compose native SQLite bootstrap tables

* refactor: share native SQLite state bootstrap

* refactor(macos): move PortGuardian state to SQLite

* test: align PortGuardian future-schema fixture

* fix(macos): reserve PortGuardian ledger across tunnel spawn

* fix(ci): align PortGuardian migration gates

* fix(macos): tolerate vanished SQLite sidecars

* fix(macos): revalidate PortGuardian writes

* test(macos): use sqlite identity bootstrap
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
* refactor: compose native SQLite bootstrap tables

* refactor: share native SQLite state bootstrap

* refactor(macos): move PortGuardian state to SQLite

* test: align PortGuardian future-schema fixture

* fix(macos): reserve PortGuardian ledger across tunnel spawn

* fix(ci): align PortGuardian migration gates

* fix(macos): tolerate vanished SQLite sidecars

* fix(macos): revalidate PortGuardian writes

* test(macos): use sqlite identity bootstrap
steipete added a commit that referenced this pull request Oct 13, 2026
* refactor(apple): simplify old shared and macOS bookkeeping

Replace redundant generations with existing cancellation or actual owner
identity, consolidate parallel fallback/policy paths, and remove test-only
forwarding layers. Preserve authority, FIFO, durable state, resource bounds,
public protocol/config shapes, signing, permissions, and visible rendering.

Reuse canonical session-key normalization for Voice Wake delivery selection:
opaque Signal group IDs remain case-sensitive and main aliases are not added.
Use canonical IP-literal policy for discovery labels and remote CLI validation.

Best-effort tradeoffs accepted

- Palette generation (#159350): synthetic direct completions bypassed the sole cancellation-owning caller; unsupported future callers can show stale results until the next search. Current cancellation/request/agent checks remain.
- Link preview generation (#160710): synthetic URL replacement without caller cancellation is outside the SwiftUI task lifecycle; a late cosmetic result can remain until the next refresh. Network/SSRF checks and bounded caches remain.
- Sidebar preview generation (#147197): same-request overlapping cache reads can finish out of order; no linked human failure report, and a later refresh replaces the cosmetic projection. Owner/request checks remain.
- Source-preview producer revision (#148906): duplicate of exact task cancellation, with no human failure report. Consumer revision and authenticated resource authority remain.
- Mermaid generations (#135470/#135746): feature stress fixtures, no linked human race report. Exact subscriber cancellation and job/WebView identity retain the same admission; no extra failure accepted.
- Camera JPEG UUID (#107879): duplicates exact task cancellation; #107804 was a human feature request, not a generation-specific incident. Captured session/agent/route and attachment admission remain.
- Discovery generation (#145435): speculative queued callbacks, no linked human incident. A stopped browser may publish one late discovery projection; next discovery/refresh repairs it. Connection authority remains separate.
- FSEvents generation (#145453): synthetic stop/restart fixtures, no linked human incident. An old callback after restart may cause one extra refresh; serial lifecycle ownership and pending-work cancellation remain.
- Menu generations (#139688): feature-local late-result fixtures, no linked human incident. Exact task cancellation replaces duplicate tokens; drain-before-disconnect and real consumer/window authority remain.
- Cron generation (#131466/#137502): #138209 cut every load over to one cancel-and-drain chain. No direct concurrent load caller remains; cancellation and physical source leases stay checked after awaits.
- WebChat visibility acknowledgement/retry (#113634/#137089): synthetic timeout/reconnect interleavings, no linked human incident. A timed-out visibility update is best effort until the next transition/reconnect; FIFO and live socket leases remain.
- WebChat cleanup UUID (#113634/#137089): retain one bounded completed Task handle per live connection instead of matching cleanup tokens. Completion releases captures; replacement/retirement removes the handle.
- Child-exit polling (#145437): synthetic missed-notification coverage, no linked human report. A lost OS exit notification may wait for the existing deadline; final non-reaping liveness/status checks and cleanup remain.
- Realtime iterator borrowing trap (#156772): every real consumer awaits its own iterator sequentially. Unsupported concurrent next calls no longer get a custom custody protocol; bounded stream/cancellation/socket checks remain.
- Receipt projection admission (#161745): both real callers already match receipt and row identity immediately before synchronous projection. Those effect checks remain; no unsupported internal caller is defended twice.
- Recap attribution heuristics (#112188/#113084): synthetic guard matrix, no linked human race report. Missing initial rows or very late unrelated completion may supply a cosmetic footer; per-session freshness, failed-turn handling and settled results remain.
- PortGuardian per-write schema scans (#110527): synthetic live-handle version advance, no linked human incident. Concurrent external schema upgrades are best effort until reopen; initial admission, migration locks, receipts, transactions and durability remain.
- Unread queue counter (#110019): actual Task equality replaces the duplicate integer token. Exact-tail reclamation, bounded bookkeeping, FIFO and route authority remain unchanged.

Review dispositions: the claimed Task compilation failure is disproved by the
selected SDK's Equatable conformance and native builds. Repeated receipt
identity admission is unnecessary at its internal projector because both real
callers retain it immediately before projection. Per-write schema revalidation
was declined under the explicit best-effort policy above.

Proof and scope

Net production reduction: 369 lines (148 added, 517 deleted), excluding tests.
Fresh seven-day census permits all substantive production edits; the only
recent caller change is the unavoidable one-line fallback-to-parse rename.

Shared Swift build passed. Final focused shared tests passed 396 cases in six
suites (6.683s execution), Watch decoder tests passed five cases (0.003s), and
isolated whole-owner native tests passed 16 cases. macOS SwiftPM compiled all
products and the test bundle. Final macOS and iOS/Watch xcodebuild builds passed
(89.60s and 120.87s wall), without signing changes or app launches.

Canonical Apple lint/format checks passed; the initial iOS format failure in
WatchCommands was ours and corrected, with no gate weakened. Lint-suppression
tests passed 3/3 (14.09s wall). Earlier runtime cycles and Madge each reported 0;
the TypeScript graph is unchanged. Native localization stayed at 4476 entries.
The 45 original packaging/elevation timeout cases passed one focused retry
(94.79s wall), with no assertion/budget change and no claim of a diagnosed fix.

Known gaps: seven issues remained in the earlier ChatStreamReplayTests
narration=false package cases; causality/current-main attribution is unproven.
App-hosted macOS tests were not executed on the operator desktop. No hosted CI
or PR was started: the explicit BELOW-500 rule requires a branch-only handoff.

* refactor(ui): consolidate old UI owners and validation

Share route decoding, attachment retention, gallery preparation, transient
identity encoding, override copying, and extension classification. Remove
duplicate admission/schema mirrors and obsolete supported-browser fallbacks.
Both Lit and Solid paths remain; no rendering change is intended. No config,
protocol, persisted shape, dependency, or public SDK change.

Best-effort tradeoffs accepted

- Malformed internal native requests (#140988): all callers are typed and
  native hosts validate at the effect; their error replaces the renderer mirror.
- Worker replacement during an identity query (#140484): added for synthetic
  autoreview interleavings, not a human incident. Return false; normal worker
  announcements and foreground recovery observe the next active worker.
- Native readiness changing between synchronous checks (#140484/#109719):
  rely on queued events. A broken native event can require another worker event
  or reload; camera readiness retains its existing five-second error deadline.
- Overlapping application-root health reporters (#152638): startup mounts one
  root. Unsupported overlapping roots are last-publication-wins; the actual
  reported health/status feature and native trusted-document checks remain.
- Polling after stop (#139704): its sole owner retires eligibility first.
  Scheduling now uses that owner admission, not a separate read-only generation.
- Resetting an observer without retiring its connection (#116887): no production
  caller does this. Canonical connection epochs remain the sole retirement owner;
  unsupported direct live-scope reset no longer fences an old response separately.
- Upload policy changing during local reads (#158567): decoded/hash work can
  finish. Draft publication and every upload request retain live policy checks.
- Missing supported browser primitives (#105240/#151388/#100024/#102745):
  unsupported runtimes error instead of code-point initials, skipped input yield,
  wall-clock timing, or approximate microtask paint. The human progress-card fix
  in #151386 keeps its browser yield and durable FIFO handoff unchanged.
- URL APIs disappearing after URL creation (#100024/#149330): supported browsers
  keep paired APIs. An unsupported replaced global can throw during cleanup;
  undefined URLs, creation fallback, cancellation and release ordering remain.
- Malformed internal MCP calls bypassing AppBridge (#161747): may throw. The SDK
  still rejects malformed wire blocks before dispatch, proved over real in-memory
  App/AppBridge transport. UI content, authority, confirmation and custody policy
  remain. The introducing PR cites no human incident for the second mirror.

Production: +176/-394, net -218 lines across 21 eligible old files. Tests: +30.
Focused owner/sibling tests, targeted types/lint/format, lint-suppression and
independent P0-P2 review pass. Import edges are unchanged; runtime/Madge cycle
proof remains zero. Whole-tree Knip timed out at existing limits; heavy gallery
renderer runs did not reach assertions, while its owning controller suite passed.

* refactor(ui): remove obsolete Fetch capability branch

The supported Control UI browser floor includes Fetch. Start attachment
metadata reads directly rather than leaving an unsupported runtime in a
permanent checking state.

Best-effort tradeoffs accepted

- Missing global Fetch: the guard originated in #64104, whose feature report
  cites no human missing-Fetch incident. An unsupported runtime that replaces
  Fetch now reaches the existing rejected-request/unavailable path. Metadata
  validation, auth/tickets, allow POST, cancellation, resource admission,
  expiry and bounded retry remain unchanged. No intended rendering change.

Unchanged lifecycle baseline: 21/21, 25.09 s. Final lifecycle and attachment
siblings: 50/50, 14.77 s. UI types, typed lint, formatting and lint-suppression
checks pass. This cut removes five production lines including formatter
reflow, bringing the lane to 223 net production lines removed.
Fresh independent P0-P2 review is scoped-clean with no actionable findings.

* fix(ui): use global frame scheduling APIs

Preserve double-frame paint timing and cancellation without requiring a Window object in renderer-free hosts that supply the standard global APIs. The existing access suite reproduces seven unhandled errors before this fix and passes on main; all 130 affected cases plus 262 timing/state/send sibling cases now pass without test changes.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 14, 2026
…#170823)

* refactor(apple): simplify old shared and macOS bookkeeping

Replace redundant generations with existing cancellation or actual owner
identity, consolidate parallel fallback/policy paths, and remove test-only
forwarding layers. Preserve authority, FIFO, durable state, resource bounds,
public protocol/config shapes, signing, permissions, and visible rendering.

Reuse canonical session-key normalization for Voice Wake delivery selection:
opaque Signal group IDs remain case-sensitive and main aliases are not added.
Use canonical IP-literal policy for discovery labels and remote CLI validation.

Best-effort tradeoffs accepted

- Palette generation (openclaw#159350): synthetic direct completions bypassed the sole cancellation-owning caller; unsupported future callers can show stale results until the next search. Current cancellation/request/agent checks remain.
- Link preview generation (openclaw#160710): synthetic URL replacement without caller cancellation is outside the SwiftUI task lifecycle; a late cosmetic result can remain until the next refresh. Network/SSRF checks and bounded caches remain.
- Sidebar preview generation (openclaw#147197): same-request overlapping cache reads can finish out of order; no linked human failure report, and a later refresh replaces the cosmetic projection. Owner/request checks remain.
- Source-preview producer revision (openclaw#148906): duplicate of exact task cancellation, with no human failure report. Consumer revision and authenticated resource authority remain.
- Mermaid generations (openclaw#135470/openclaw#135746): feature stress fixtures, no linked human race report. Exact subscriber cancellation and job/WebView identity retain the same admission; no extra failure accepted.
- Camera JPEG UUID (openclaw#107879): duplicates exact task cancellation; openclaw#107804 was a human feature request, not a generation-specific incident. Captured session/agent/route and attachment admission remain.
- Discovery generation (openclaw#145435): speculative queued callbacks, no linked human incident. A stopped browser may publish one late discovery projection; next discovery/refresh repairs it. Connection authority remains separate.
- FSEvents generation (openclaw#145453): synthetic stop/restart fixtures, no linked human incident. An old callback after restart may cause one extra refresh; serial lifecycle ownership and pending-work cancellation remain.
- Menu generations (openclaw#139688): feature-local late-result fixtures, no linked human incident. Exact task cancellation replaces duplicate tokens; drain-before-disconnect and real consumer/window authority remain.
- Cron generation (openclaw#131466/openclaw#137502): openclaw#138209 cut every load over to one cancel-and-drain chain. No direct concurrent load caller remains; cancellation and physical source leases stay checked after awaits.
- WebChat visibility acknowledgement/retry (openclaw#113634/openclaw#137089): synthetic timeout/reconnect interleavings, no linked human incident. A timed-out visibility update is best effort until the next transition/reconnect; FIFO and live socket leases remain.
- WebChat cleanup UUID (openclaw#113634/openclaw#137089): retain one bounded completed Task handle per live connection instead of matching cleanup tokens. Completion releases captures; replacement/retirement removes the handle.
- Child-exit polling (openclaw#145437): synthetic missed-notification coverage, no linked human report. A lost OS exit notification may wait for the existing deadline; final non-reaping liveness/status checks and cleanup remain.
- Realtime iterator borrowing trap (openclaw#156772): every real consumer awaits its own iterator sequentially. Unsupported concurrent next calls no longer get a custom custody protocol; bounded stream/cancellation/socket checks remain.
- Receipt projection admission (openclaw#161745): both real callers already match receipt and row identity immediately before synchronous projection. Those effect checks remain; no unsupported internal caller is defended twice.
- Recap attribution heuristics (openclaw#112188/openclaw#113084): synthetic guard matrix, no linked human race report. Missing initial rows or very late unrelated completion may supply a cosmetic footer; per-session freshness, failed-turn handling and settled results remain.
- PortGuardian per-write schema scans (openclaw#110527): synthetic live-handle version advance, no linked human incident. Concurrent external schema upgrades are best effort until reopen; initial admission, migration locks, receipts, transactions and durability remain.
- Unread queue counter (openclaw#110019): actual Task equality replaces the duplicate integer token. Exact-tail reclamation, bounded bookkeeping, FIFO and route authority remain unchanged.

Review dispositions: the claimed Task compilation failure is disproved by the
selected SDK's Equatable conformance and native builds. Repeated receipt
identity admission is unnecessary at its internal projector because both real
callers retain it immediately before projection. Per-write schema revalidation
was declined under the explicit best-effort policy above.

Proof and scope

Net production reduction: 369 lines (148 added, 517 deleted), excluding tests.
Fresh seven-day census permits all substantive production edits; the only
recent caller change is the unavoidable one-line fallback-to-parse rename.

Shared Swift build passed. Final focused shared tests passed 396 cases in six
suites (6.683s execution), Watch decoder tests passed five cases (0.003s), and
isolated whole-owner native tests passed 16 cases. macOS SwiftPM compiled all
products and the test bundle. Final macOS and iOS/Watch xcodebuild builds passed
(89.60s and 120.87s wall), without signing changes or app launches.

Canonical Apple lint/format checks passed; the initial iOS format failure in
WatchCommands was ours and corrected, with no gate weakened. Lint-suppression
tests passed 3/3 (14.09s wall). Earlier runtime cycles and Madge each reported 0;
the TypeScript graph is unchanged. Native localization stayed at 4476 entries.
The 45 original packaging/elevation timeout cases passed one focused retry
(94.79s wall), with no assertion/budget change and no claim of a diagnosed fix.

Known gaps: seven issues remained in the earlier ChatStreamReplayTests
narration=false package cases; causality/current-main attribution is unproven.
App-hosted macOS tests were not executed on the operator desktop. No hosted CI
or PR was started: the explicit BELOW-500 rule requires a branch-only handoff.

* refactor(ui): consolidate old UI owners and validation

Share route decoding, attachment retention, gallery preparation, transient
identity encoding, override copying, and extension classification. Remove
duplicate admission/schema mirrors and obsolete supported-browser fallbacks.
Both Lit and Solid paths remain; no rendering change is intended. No config,
protocol, persisted shape, dependency, or public SDK change.

Best-effort tradeoffs accepted

- Malformed internal native requests (openclaw#140988): all callers are typed and
  native hosts validate at the effect; their error replaces the renderer mirror.
- Worker replacement during an identity query (openclaw#140484): added for synthetic
  autoreview interleavings, not a human incident. Return false; normal worker
  announcements and foreground recovery observe the next active worker.
- Native readiness changing between synchronous checks (openclaw#140484/openclaw#109719):
  rely on queued events. A broken native event can require another worker event
  or reload; camera readiness retains its existing five-second error deadline.
- Overlapping application-root health reporters (openclaw#152638): startup mounts one
  root. Unsupported overlapping roots are last-publication-wins; the actual
  reported health/status feature and native trusted-document checks remain.
- Polling after stop (openclaw#139704): its sole owner retires eligibility first.
  Scheduling now uses that owner admission, not a separate read-only generation.
- Resetting an observer without retiring its connection (openclaw#116887): no production
  caller does this. Canonical connection epochs remain the sole retirement owner;
  unsupported direct live-scope reset no longer fences an old response separately.
- Upload policy changing during local reads (openclaw#158567): decoded/hash work can
  finish. Draft publication and every upload request retain live policy checks.
- Missing supported browser primitives (openclaw#105240/openclaw#151388/openclaw#100024/openclaw#102745):
  unsupported runtimes error instead of code-point initials, skipped input yield,
  wall-clock timing, or approximate microtask paint. The human progress-card fix
  in openclaw#151386 keeps its browser yield and durable FIFO handoff unchanged.
- URL APIs disappearing after URL creation (openclaw#100024/openclaw#149330): supported browsers
  keep paired APIs. An unsupported replaced global can throw during cleanup;
  undefined URLs, creation fallback, cancellation and release ordering remain.
- Malformed internal MCP calls bypassing AppBridge (openclaw#161747): may throw. The SDK
  still rejects malformed wire blocks before dispatch, proved over real in-memory
  App/AppBridge transport. UI content, authority, confirmation and custody policy
  remain. The introducing PR cites no human incident for the second mirror.

Production: +176/-394, net -218 lines across 21 eligible old files. Tests: +30.
Focused owner/sibling tests, targeted types/lint/format, lint-suppression and
independent P0-P2 review pass. Import edges are unchanged; runtime/Madge cycle
proof remains zero. Whole-tree Knip timed out at existing limits; heavy gallery
renderer runs did not reach assertions, while its owning controller suite passed.

* refactor(ui): remove obsolete Fetch capability branch

The supported Control UI browser floor includes Fetch. Start attachment
metadata reads directly rather than leaving an unsupported runtime in a
permanent checking state.

Best-effort tradeoffs accepted

- Missing global Fetch: the guard originated in openclaw#64104, whose feature report
  cites no human missing-Fetch incident. An unsupported runtime that replaces
  Fetch now reaches the existing rejected-request/unavailable path. Metadata
  validation, auth/tickets, allow POST, cancellation, resource admission,
  expiry and bounded retry remain unchanged. No intended rendering change.

Unchanged lifecycle baseline: 21/21, 25.09 s. Final lifecycle and attachment
siblings: 50/50, 14.77 s. UI types, typed lint, formatting and lint-suppression
checks pass. This cut removes five production lines including formatter
reflow, bringing the lane to 223 net production lines removed.
Fresh independent P0-P2 review is scoped-clean with no actionable findings.

* fix(ui): use global frame scheduling APIs

Preserve double-frame paint timing and cancellation without requiring a Window object in renderer-free hosts that supply the standard global APIs. The existing access suite reproduces seven unhandled errors before this fix and passes on main; all 130 affected cases plus 262 timing/state/send sibling cases now pass without test changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: ios App: ios app: macos App: macos docs Improvements or additions to documentation maintainer Maintainer-authored PR 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. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts 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.

1 participant