Skip to content

feat(mac): harden Peekaboo elevation cutovers - #124564

Merged
steipete merged 24 commits into
mainfrom
codex/elevation-hardening-current-main
Aug 17, 2026
Merged

steipete merged 24 commits into
mainfrom
codex/elevation-hardening-current-main

Conversation

@steipete

@steipete steipete commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The unattended macOS computer-control host could not safely adopt, upgrade, or recover an existing background app or canonical node owner while proving that transferred OpenClaw and Peekaboo artifacts came from the intended source generations. A crash during cutover could also leave recovery coordinates only in shell memory.

Why This Change Was Made

The elevation workflow now treats packaging, transfer, install, migration, recovery, and Gateway reconnection as one fail-closed transaction. A native pre-SwiftUI maintenance dispatcher owns exclusive rename and durable file, directory, and app-tree sync. The portable installer uses one independently copied and hash-bound helper with no fallback executables.

Before the first custody mutation, the installer publishes a fsynced prepared receipt containing a unique transaction ID, exact rollback paths, source identities, per-architecture CDHashes, migration sidecar identities, and owner state. Pending and final receipts correlate by transaction ID. Every rollback payload and staged app tree is durably synced before state advancement; every exclusive rename syncs its destination namespace. Recovery is idempotent across SIGKILL, owner restart, same-content replacement, missing or damaged apps, and interrupted receipt publication.

Migration custody uses authenticated renamex_np(RENAME_EXCL) and durable VolumeUUID/inode/generation identities. Unexpected or concurrently replaced entries are preserved rather than overwritten or trusted. Canonical-node environment and wrapper paths, content, modes, identities, hashes, and the digest-verified LaunchAgent plist remain bound through explicit recovery.

Packaging builds each architecture in an independent disposable Swift package root. It compiles against a read-only authenticated Peekaboo snapshot and proves every non-Peekaboo lock pin is unchanged before and after compilation. The final Peekaboo pin remains a separate two-file update after Peekaboo certification freezes.

User Impact

Release operators can migrate or repeatedly upgrade the unattended macOS computer-control host without foreground activation, silently losing node identity, accepting replacement files, or destroying recoverable app and LaunchAgent state. A killed installer leaves an operator-visible pending transaction that status refuses and recover can finish on its first attempt.

Evidence

  • Exact PR head: 7e496819e5c6fd0f34cf1bdabdcd3d3aced8c7bb.
  • macOS elevation plus package/source-attestation suites: 142/142 passed (89 elevation, 53 package).
  • Native maintenance-entry suite: 8/8 passed after a full Swift build.
  • A real universal debug package build compiled both arm64 and x86_64 from the authenticated read-only Peekaboo snapshot, verified the frozen lock around both builds, assembled the bundle, completed Developer ID signing, passed strict code-sign verification, and reported both architectures.
  • Bash syntax, repository-configured ShellCheck, oxfmt, SwiftFormat, strict SwiftLint (0 violations, 0 serious), root test typecheck, scripts lint, dependency guards, secret scan, and git diff --check passed.
  • Final local P0-P2 review of the last recovery-order correction reported no findings at 0.94 confidence. Whole-branch review findings were repaired with focused regressions; claims relying on earlier schema-3 compatibility were rejected because those shapes never shipped.
  • No signing for release, notarization submission, application install, launchd mutation, TCC change, live Gateway change, AppleScript/JXA, or virtualization was performed in this source lane. Immutable signed physical-host proof follows after the separate final Peekaboo pin.

@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: macos App: macos scripts Repository scripts labels Aug 16, 2026
@steipete
steipete marked this pull request as ready for review August 16, 2026 12:30
@openclaw-barnacle openclaw-barnacle Bot added size: XL maintainer Maintainer-authored PR labels Aug 16, 2026
@clawsweeper clawsweeper Bot added 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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 16, 2026
@clawsweeper

clawsweeper Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 17, 2026, 4:57 AM ET / 08:57 UTC.

ClawSweeper review

What this changes

The PR hardens the macOS Peekaboo elevation package, installer, migration, and recovery flow with artifact attestation and durable transaction state.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

The PR has a blocking recovery-custody flaw: its new restore helper can overwrite a concurrently recreated LaunchAgent or receipt, contrary to the fail-closed cutover invariant. Keep it open for a no-clobber recovery repair.

Priority: P1
Reviewed head: 7e496819e5c6fd0f34cf1bdabdcd3d3aced8c7bb

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch has substantial focused validation, but the recovery overwrite defect must be repaired before it is merge-ready.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored source hardening PR documents source-lane validation; the owner explicitly retains signed physical-host install and recovery proof as a downstream gate.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored source hardening PR documents source-lane validation; the owner explicitly retains signed physical-host install and recovery proof as a downstream gate.
Evidence reviewed 5 items Recovery overwrite: The new recovery helper stages a verified file but uses destination-replacing mv, so a concurrently recreated destination is deleted before its digest check can detect the race.
Affected recovery owners: The helper restores both the elevation LaunchAgent and install receipt, making the overwrite reachable during failed-recovery reversal.
Established owner-boundary pattern: The same patch already uses authenticated exclusive rename and explicit preservation for raced migration paths, which is the appropriate pattern for this recovery write.
Findings 1 actionable finding [P1] Preserve replacement files during recovery
Security Needs attention Recovery restore clobbers raced destination: The new restore helper replaces its destination with a verified backup without first proving the destination remains transaction-owned, deleting a concurrent plist or receipt replacement.

How this fits together

The macOS elevation host packages a signed computer-control application and installs it as a background owner. Its installer transfers app, LaunchAgent, and receipt custody before reconnecting the host to the Gateway.

flowchart LR
A[Release source and Peekaboo pin] --> B[Signed package and receipt]
B --> C[Portable installer]
C --> D[Durable prepared transaction]
D --> E[App and LaunchAgent cutover]
E --> F[Recovery or final receipt]
F --> G[Background host reconnects]
Loading

Before merge

  • Preserve replacement files during recovery (P1) - restore_file_atomically uses mv after staging the backup, which replaces an entry recreated at the destination before the later digest check. This helper restores the elevation plist and install receipt during recovery, so a competing owner’s replacement is silently deleted. Use the existing exclusive, identity-bound custody flow and add a race regression for both destinations.
  • Resolve security concern: Recovery restore clobbers raced destination - The new restore helper replaces its destination with a verified backup without first proving the destination remains transaction-owned, deleting a concurrent plist or receipt replacement.
  • Resolve merge risk (P1) - Existing release-operator automation must adopt the new source-pin, receipt, and receipt-digest command contract; the physical signed-host proof remains a downstream gate after the final Peekaboo pin.
  • Complete next step (P2) - A protected, security-sensitive PR needs its author or a macOS owner to make the concrete no-clobber recovery repair before merge.

Findings

  • [P1] Preserve replacement files during recovery — scripts/mac-elevation-host.sh:520
  • [high] Recovery restore clobbers raced destination — scripts/mac-elevation-host.sh:520
Agent review details

Security

Needs attention: Recovery can overwrite concurrently recreated custody files, defeating the PR’s fail-closed preservation guarantee.

PR surface

Tests +4505, Docs +66, Other +2979. Total +7550 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 4635 130 +4505
Docs 2 89 23 +66
Config 0 0 0 0
Generated 0 0 0 0
Other 5 3079 100 +2979
Total 9 7803 253 +7550

Review metrics

Metric Value Why it matters
Production versus test LOC production +3098/-123; tests +4705/-130 This is a large security-sensitive installer rewrite, so the recovery owner boundary needs focused scrutiny beyond aggregate diff size.
Operator authentication inputs package +1 required source pin; install +2 required receipt inputs Existing internal release automation must supply the new source and authenticated artifact coordinates.

Stored data model

Persistent data-model change detected: migration/backfill/repair: apps/macos/README.md, serialized state: test/scripts/package-mac-app.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Make recovery no-clobber (recommended)
    Use authenticated exclusive custody or an equivalent identity-bound swap for recovery restores, preserving any unexpected plist or receipt instead of replacing it.

Technical review

Best possible solution:

Replace recovery’s replacing rename with identity-bound exclusive custody that preserves an unexpected destination, then add a race regression covering both the elevation plist and receipt restore paths.

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

Yes, source-reproducible: recreate the receipt or elevation plist after recovery snapshots it and before the direct destination-replacing move; the replacement is overwritten rather than preserved.

Is this the best way to solve the issue?

No. The patch already has an authenticated exclusive-custody pattern for raced migration files, and recovery should use that pattern instead of a replacing move.

Full review comments:

  • [P1] Preserve replacement files during recovery — scripts/mac-elevation-host.sh:520
    restore_file_atomically uses mv after staging the backup, which replaces an entry recreated at the destination before the later digest check. This helper restores the elevation plist and install receipt during recovery, so a competing owner’s replacement is silently deleted. Use the existing exclusive, identity-bound custody flow and add a race regression for both destinations.
    Confidence: 0.94

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored source hardening PR documents source-lane validation; the owner explicitly retains signed physical-host install and recovery proof as a downstream gate.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P1: A recovery race can delete a concurrently recreated operator-owned launch configuration or receipt.
  • merge-risk: 🚨 compatibility: The PR changes established internal package and install command inputs used by release operators.
  • merge-risk: 🚨 security-boundary: The affected recovery path handles authenticated app, LaunchAgent, and receipt custody.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored source hardening PR documents source-lane validation; the owner explicitly retains signed physical-host install and recovery proof as a downstream gate.

Evidence

Security concerns:

  • [high] Recovery restore clobbers raced destination — scripts/mac-elevation-host.sh:520
    The new restore helper replaces its destination with a verified backup without first proving the destination remains transaction-owned, deleting a concurrent plist or receipt replacement.
    Confidence: 0.94

What I checked:

  • Recovery overwrite: The new recovery helper stages a verified file but uses destination-replacing mv, so a concurrently recreated destination is deleted before its digest check can detect the race. (scripts/mac-elevation-host.sh:520, 7e496819e5c6)
  • Affected recovery owners: The helper restores both the elevation LaunchAgent and install receipt, making the overwrite reachable during failed-recovery reversal. (scripts/mac-elevation-host.sh:2469, 7e496819e5c6)
  • Established owner-boundary pattern: The same patch already uses authenticated exclusive rename and explicit preservation for raced migration paths, which is the appropriate pattern for this recovery write. (scripts/mac-elevation-host.sh:483, 7e496819e5c6)
  • Dependency boundary: Peekaboo is an affirmative packaging dependency through the macOS Swift manifest and lockfile; this finding is confined to the installer’s shell recovery logic and does not rely on a Codex runtime or protocol contract. (apps/macos/Package.swift:26, 7e496819e5c6)
  • Exact-head provenance: The reviewed head is the current PR head and records the final durability change as authored by Peter Steinberger. (scripts/mac-elevation-host.sh:520, 7e496819e5c6)

Likely related people:

  • steipete: The supplied 24-commit elevation series and exact-head commit metadata attribute the current installer and recovery work to Peter Steinberger. (role: recent elevation feature contributor; confidence: high; commits: 7e496819e5c6, 6a4541a15b4f; files: scripts/mac-elevation-host.sh, scripts/package-mac-app.sh)

Rank-up moves

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

  • Replace destination-replacing recovery restores with identity-bound no-clobber custody.
  • Add a regression that recreates the elevation plist and receipt during recovery and proves each replacement is preserved.

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 (8 earlier review cycles)
  • reviewed 2026-08-16T12:37:42.783Z sha 2e12dcdeec09d5c338da389db7e1e7e7d8eeb6c6 :: found issues before merge. :: [P1] Authenticate the portable installer before executing it | [P1] Bind canonical-node migration to the source node identity
  • reviewed 2026-08-16T12:52:10.278Z sha daaf40e :: found issues before merge. :: [P1] Authenticate the portable installer before it runs | [P1] Bind canonical-node migration to its explicit node identity
  • reviewed 2026-08-16T14:04:06.994Z sha 4d7a229 :: found issues before merge. :: [P1] Bind installer verification to the executing script
  • reviewed 2026-08-16T14:45:31.222Z sha 5cdacb0 :: found issues before merge. :: [P1] Reject stdin-fed loose installers
  • reviewed 2026-08-17T03:47:50.304Z sha 132c62c :: found issues before merge. :: [P1] Make migration custody exclusive and identity-bound | [P1] Authenticate every fallback rename helper
  • reviewed 2026-08-17T07:59:00.111Z sha c49fa7a :: needs maintainer review before merge. :: none
  • reviewed 2026-08-17T08:37:18.354Z sha 5325484a61f8e1769306d1c1776e86c6581fcca1 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-17T08:45:55.378Z sha 5325484a61f8e1769306d1c1776e86c6581fcca1 :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the codex/elevation-hardening-current-main branch from 2e12dcd to daaf40e Compare August 16, 2026 12:45
@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 Aug 16, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 16, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@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 Aug 16, 2026
@steipete steipete self-assigned this Aug 16, 2026
@steipete
steipete force-pushed the codex/elevation-hardening-current-main branch from 5cdacb0 to 132c62c Compare August 17, 2026 03:41
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 17, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@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 Aug 17, 2026
@steipete
steipete force-pushed the codex/elevation-hardening-current-main branch from 132c62c to c49fa7a Compare August 17, 2026 07:53
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The exact head is now c49fa7ae667d91a4c602f1681e8f2c10142bd485.

The two prior P1 findings are closed: migration custody uses the single authenticated exclusive-rename helper and no fallback executable exists. The branch also now persists and fsyncs a UUID-bound prepared transaction before any custody mutation, binds durable sidecar and rollback identities through recovery, and resumes after SIGKILL or restored-owner restart.

Exact local proof is 142/142 elevation/package tests plus 8/8 native maintenance-entry tests. The remaining physical signed install/recovery evidence is intentionally after the separate final Peekaboo pin, as stated in the PR body.

@steipete
steipete force-pushed the codex/elevation-hardening-current-main branch from 5325484 to 7e49681 Compare August 17, 2026 08:52
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The exact head is now 7e496819e5c6fd0f34cf1bdabdcd3d3aced8c7bb. This is a patch-equivalent rebase onto current main@5275eae4770388173e967fea1acdb69c9920334c, including the landed Control UI baseline fix and four later unrelated main commits; git range-diff reports all 24 branch commits equivalent.

The two prior P1 findings are closed: migration custody uses the single authenticated exclusive-rename helper and no fallback executable exists. The branch also now persists and fsyncs a UUID-bound prepared transaction before any custody mutation, binds durable sidecar and rollback identities through recovery, and resumes after SIGKILL or restored-owner restart.

Exact local proof is 142/142 elevation/package tests plus 8/8 native maintenance-entry tests. The remaining physical signed install/recovery evidence is intentionally after the separate final Peekaboo pin, as stated in the PR body.

@clawsweeper

clawsweeper Bot commented Aug 17, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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. labels Aug 17, 2026
@steipete
steipete merged commit b77671c into main Aug 17, 2026
155 checks passed
@steipete
steipete deleted the codex/elevation-hardening-current-main branch August 17, 2026 09:20
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 18, 2026
* feat(mac): harden elevation cutovers

* fix(mac): make elevation recovery transactional

* fix(mac): revalidate elevation owner shutdown

* fix(mac): quiesce elevation recovery owners

* fix(mac): close elevation artifact and recovery races

* fix(mac): use signed exclusive app renames

* fix(mac): defer elevation hangup signals

* fix(mac): restore receipts during elevation rollback

* fix(mac): bind elevation receipts to both architectures

* fix(mac): close elevation attestation races

* fix(mac): bind elevation proof to final objects

* fix(mac): keep elevation rollback independently trusted

* fix(mac): validate every rollback generation

* fix(mac): authenticate legacy elevation recovery

* fix(mac): attest recursive Peekaboo sources

* fix(mac): recover when elevation app is unavailable

* fix(mac): preserve raced recovery custody

* test(mac): preserve missing-tool coverage

* test(mac): register recursive gitlink fixture

* fix(mac): authenticate all elevation custody

* fix(mac): bind elevation build and recovery inputs

* fix(mac): persist elevation recovery transactions

* fix(mac): durably publish elevation custody

* fix(mac): complete elevation transaction durability
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: macos App: macos docs Improvements or additions to documentation 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. scripts Repository scripts size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant