Skip to content

fix(macos): recover node startup after legacy identity recreation - #120610

Merged
steipete merged 1 commit into
mainfrom
steipete/sharp-ritchie-023c74
Aug 8, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/sharp-ritchie-023c74

Conversation

@steipete

@steipete steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Closes #120608

What Problem This Solves

Fixes an issue where macOS app users could lose native node startup after an older app build recreated retired device identity JSON files alongside valid canonical SQLite identities. The app would repeatedly report Could not access the persisted device identity, leaving node capabilities such as camera control unavailable.

Why This Change Was Made

Canonical SQLite rows now win before retired identity files are examined in both the native and TypeScript identity paths. Divergent retired files remain untouched for explicit Doctor handling, while missing canonical rows still use the existing migration flow.

Debug Mac node workers now launch the selected checkout through the freshness-aware scripts/run-node.mjs runner with an explicit checkout working directory, rather than invoking a bare launcher against potentially partial shared dist/ output. Installed/release CLI behavior is unchanged.

AI-assisted implementation and review; the behavior and ownership boundaries were independently verified against copied state.

User Impact

Affected macOS nodes recover their existing canonical identity and can connect again without rotating keys, deleting retired files, or changing the SQLite schema. Developers also get deterministic worker startup from the intended checkout and its validated build artifacts.

Evidence

Before the repair, a throwaway Swift probe against a copied state directory returned:

primary=false
node=false

After the repair, the same copied state returned:

primary=true
node=true
copied_db_and_legacy_identity_bytes_unchanged=true

Focused validation:

  • DeviceIdentityStoreTests: 37 passed
  • src/infra/device-identity.test.ts: 20 passed
  • CommandResolverTests: 26 passed
  • MacNodeHostWorkerTests: 15 passed
  • pnpm lint:swift under the Xcode toolchain: 0 violations
  • core and core-test typechecks: passed
  • full core lint matrix: passed
  • native state schema version guard: passed at v6
  • dependency, plugin-boundary, dead-export, formatting, conflict-marker, and max-lines guards: passed
  • git diff --check origin/main...HEAD: passed
  • Codex autoreview: clean, no accepted/actionable findings

The remote fast-CI backend was unavailable during local preflight, so trusted-source validation followed the documented local fallback. Hosted exact-head CI remains the landing gate.

@steipete
steipete marked this pull request as ready for review August 8, 2026 15:14
@openclaw-barnacle openclaw-barnacle Bot added app: macos App: macos size: M maintainer Maintainer-authored PR labels Aug 8, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P1 High-priority user-facing bug, regression, or broken workflow. labels Aug 8, 2026
@clawsweeper

clawsweeper Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 8, 2026, 11:41 AM ET / 15:41 UTC.

ClawSweeper review

What this changes

This PR makes valid SQLite device identities win over recreated retired JSON files and launches debug macOS node workers through the selected checkout’s freshness-aware runner.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open for normal maintainer merge handling: the focused repair correctly restores canonical SQLite identity precedence and debug worker startup, with no actionable patch defect found.

Priority: P1
Reviewed head: 35baff2cce44e0d5a4715fff3f31f2c3b197fe3d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary repair with regression coverage and successful exact-head CI, with no concrete correctness or security finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored, maintainer-labeled PR is not subject to the external-contributor proof gate; its body nevertheless reports copied-state before/after recovery.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored, maintainer-labeled PR is not subject to the external-contributor proof gate; its body nevertheless reports copied-state before/after recovery.
Evidence reviewed 7 items Canonical state owner: The PR reads and validates an existing SQLite identity before examining retired files, leaving divergent legacy artifacts for Doctor when a canonical row exists.
Native identity owner: The Swift store performs the same canonical-row-first check after directory hardening, so the native and TypeScript paths share the invariant.
Migration boundary remains intact: Doctor-owned migration remains responsible for importing or removing retired identity files; runtime only uses the canonical store.
Findings None None.
Security None None.

How this fits together

The macOS app starts a native Node worker that reads device identity state from the shared SQLite database. Retired JSON identity files are migration inputs handled by Doctor, while the launch resolver selects the worker command and working directory.

flowchart LR
A[macOS app] --> B[Node startup coordinator]
B --> C[Identity store]
C --> D{Canonical SQLite row exists?}
D -->|Yes| E[Use canonical identity]
D -->|No| F[Doctor-owned legacy migration]
B --> G[Debug worker launch resolver]
G --> H[Node worker process]
Loading

Before merge

  • Complete next step (P2) - This maintainer-owned, maintainer-labeled PR needs normal exact-head merge handling rather than a ClawSweeper repair dispatch.
Agent review details

Security

None.

PR surface

Source +5, Tests +32, Other +106. Total +143 across 12 files.

View PR surface stats
Area Files Added Removed Net
Source 1 10 5 +5
Tests 1 35 3 +32
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 10 177 71 +106
Total 12 222 79 +143

Review metrics

Metric Value Why it matters
Production versus regression coverage production +48 net, tests +95 net The production growth is justified by carrying the canonical-state and explicit-launch ownership facts through both native and TypeScript paths; the larger test delta covers the migration boundary.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/infra/device-identity.test.ts, serialized state: src/infra/device-identity.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #120608
Summary: This PR is the focused candidate repair for the linked macOS legacy-identity startup failure.

Members:

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

Technical review

Best possible solution:

Merge the canonical-state-first repair after the normal exact-head maintainer gate, preserving Doctor as the sole owner of divergent retired-file handling.

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

Yes, source-reproducible: a valid canonical row plus a divergent recreated retired identity file reaches the legacy-first gate on current main and fails before this repair.

Is this the best way to solve the issue?

Yes. Making the canonical SQLite store authoritative at both runtime owners, while retaining Doctor as the only legacy-file migration owner, is the narrowest durable fix.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: For affected macOS users, the current behavior repeatedly prevents native node startup and therefore node capabilities.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored, maintainer-labeled PR is not subject to the external-contributor proof gate; its body nevertheless reports copied-state before/after recovery.

Label justifications:

  • P1: For affected macOS users, the current behavior repeatedly prevents native node startup and therefore node capabilities.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored, maintainer-labeled PR is not subject to the external-contributor proof gate; its body nevertheless reports copied-state before/after recovery.

Evidence

What I checked:

Likely related people:

  • steipete: Current PR authorship plus the accessible history for SQLite identity migration, interrupted import handling, and macOS node-host work connect this person to the owner boundary. (role: feature owner and recent area contributor; confidence: high; commits: 35baff2cce44; files: apps/shared/OpenClawKit/Sources/OpenClawKit/DeviceIdentitySQLiteStore.swift, apps/macos/Sources/OpenClaw/NodeMode/MacNodeModeCoordinator.swift, src/infra/device-identity.ts)
  • Alix-007: Accessible base blame attributes the prior TypeScript legacy-first gate to commit 50ec557; the shallow history prevents stronger attribution. (role: current source introducer; confidence: low; commits: 50ec5570; files: src/infra/device-identity.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head 35baff2:

@steipete
steipete merged commit d9ff862 into main Aug 8, 2026
186 of 191 checks passed
@steipete
steipete deleted the steipete/sharp-ritchie-023c74 branch August 8, 2026 15:54
@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 9, 2026
steipete added a commit that referenced this pull request Aug 22, 2026
…way readiness (#126748)

* fix(state): keep divergent retired device identity from blocking gateway readiness

Classify a divergent retired identity file as a startup notice when the canonical SQLite identity remains valid and authoritative under #120610. Preserve the fatal warning for missing or invalid canonical state, so the readiness gate itself remains unchanged.

Fixes #117270.

Release note: prevents gateway crash loops caused by a recreated retired device identity JSON after a verified SQLite migration.

* fix(state): preserve device identity migration receipt integrity

Reuse canonical SQLite identity validation and retain incomplete receipts for preserved divergent claims.

Co-authored-by: Vito Cappello <[email protected]>

---------

Co-authored-by: VACInc <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 22, 2026
…way readiness (openclaw#126748)

* fix(state): keep divergent retired device identity from blocking gateway readiness

Classify a divergent retired identity file as a startup notice when the canonical SQLite identity remains valid and authoritative under openclaw#120610. Preserve the fatal warning for missing or invalid canonical state, so the readiness gate itself remains unchanged.

Fixes openclaw#117270.

Release note: prevents gateway crash loops caused by a recreated retired device identity JSON after a verified SQLite migration.

* fix(state): preserve device identity migration receipt integrity

Reuse canonical SQLite identity validation and retain incomplete receipts for preserved divergent claims.

Co-authored-by: Vito Cappello <[email protected]>

---------

Co-authored-by: VACInc <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: macos App: macos maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

macOS node startup fails after legacy identity files reappear

1 participant