Skip to content

test(macos): block real process fallthrough - #113337

Merged
steipete merged 3 commits into
mainfrom
steipete/test-macos-process-isolation
Jul 28, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/test-macos-process-isolation

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

macOS unit tests can race shared launch-agent test hooks and fall through to the real openclaw gateway CLI. Another unit test launches a real orphaned SSH child on a fixed port solely to inspect process metadata.

Why This Change Was Made

In DEBUG test processes, un-intercepted daemon commands now fail closed before command resolution or ShellExecutor execution. ProcessInfo.isRunningTests now recognizes SwiftPM's swiftpm-testing-helper and legacy swiftpm-xctest-helper runners, with injectable resolver coverage. The launch-agent suite is serialized.

The real SSH child test is replaced by a current-process metadata probe. Orphan/reap classification remains covered by the adjacent synthetic process-info matrix, so the unit suite no longer launches SSH or depends on a fixed port.

User Impact

macOS tests can no longer invoke the operator's real gateway CLI or create stray SSH children. Production release behavior is unchanged; the fail-closed branch is DEBUG-only and test-runner-gated.

Evidence

  • Full Xcode beta build completed successfully.
  • Focused Swift Testing run:
    • 3 suites passed
    • 31 tests passed
    • no SSH child launched
    • un-intercepted daemon command returned the fail-closed test error
  • git diff --check: passed
  • Formal Codex autoreview: clean, no accepted/actionable findings

Raw swift test required staging SwiftPM's built Sparkle framework into the disposable XCTest bundle before execution; exact-head macOS CI owns the normal packaged test environment.

AI-assisted: yes.

@openclaw-barnacle openclaw-barnacle Bot added app: macos App: macos size: S maintainer Maintainer-authored PR labels Jul 24, 2026
@steipete
steipete marked this pull request as ready for review July 24, 2026 14:03
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jul 24, 2026
@clawsweeper

clawsweeper Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 24, 2026, 10:08 AM ET / 14:08 UTC.

ClawSweeper review

What this changes

The PR prevents macOS tests from executing an unmocked real gateway daemon command, recognizes SwiftPM test helpers, serializes shared launch-agent tests, and replaces an SSH-orphan test with a current-process metadata probe.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This fresh, maintainer-labeled PR remains necessary as the landing vehicle for macOS test isolation. The patch appears correct: it keeps the production gateway path outside the DEBUG-only guard, blocks test fallthrough before command resolution, and replaces a real SSH child with deterministic process-metadata coverage; the remaining action is normal merge review after the active macOS checks finish.

Priority: P3
Reviewed head: 2c7ed371764602e7d873098582c8abb2e13c1c09

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, well-scoped native-test hardening patch with direct after-fix behavior evidence and no supported correctness finding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR records an after-fix focused native test run that observed the fail-closed daemon result and no SSH child, alongside a successful Xcode beta build; redact any local paths or identifiers if more terminal output is added.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR records an after-fix focused native test run that observed the fail-closed daemon result and no SSH child, alongside a successful Xcode beta build; redact any local paths or identifiers if more terminal output is added.
Evidence reviewed 5 items Fail-closed command boundary: The proposed DEBUG-only branch returns an error before resolving or executing the gateway command when a test has not explicitly intercepted daemon calls.
Test-runner contract coverage: The resolver treats XCTest bundles, XCTest environment variables, and both SwiftPM helper process names as tests; focused tests cover each positive case and a normal application negative case.
Deterministic replacement for live SSH child: The PR removes the test that spawned an orphaned SSH process on a fixed port and retains process-info coverage through a local current-process probe plus the adjacent synthetic matrix described in the PR.
Findings None None.
Security None None.

How this fits together

The macOS app’s launch-agent manager invokes gateway lifecycle commands, while native IPC tests exercise those paths. Test-runner detection selects a DEBUG-only test safeguard so tests must explicitly intercept daemon commands instead of reaching the operator’s installed gateway CLI.

flowchart LR
  A[macOS IPC tests] --> B[Test-runner detection]
  B --> C[Launch-agent manager]
  C --> D{Explicit test interception?}
  D -->|Yes| E[Mocked daemon result]
  D -->|No during tests| F[Fail-closed test error]
  D -->|Production build| G[Gateway CLI command]
  A --> H[Process metadata coverage]
Loading

Before merge

  • Resolve merge risk (P1) - The PR is reported as mergeable but behind its base and the macOS Swift/dead-code checks are still in progress, so the exact head should receive a final mergeability and check refresh before landing.
  • Complete next step (P2) - This active, maintainer-labeled implementation PR has no concrete repair finding for an automated fix lane; finish normal merge review after its active macOS checks and merge refresh.
Agent review details

Security

None.

PR surface

Other +22. Total +22 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 5 79 57 +22
Total 5 79 57 +22

Review metrics

None.

Stored data model

Persistent data-model change detected: serialized state: apps/macos/Tests/OpenClawIPCTests/GatewayLaunchAgentManagerTests.swift. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the focused DEBUG-only isolation guard once the active macOS checks complete and the rebased merge result still proves that release builds retain the existing gateway-command path.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the focused DEBUG-only isolation guard once the active macOS checks complete and the rebased merge result still proves that release builds retain the existing gateway-command path.

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

Yes, from source and the PR’s focused test: disable interception in a DEBUG test process, invoke a gateway daemon action, and verify it returns the explicit fail-closed error instead of resolving the real CLI. The supplied proof reports that this path was observed after the change.

Is this the best way to solve the issue?

Yes. Guarding the single daemon-command execution boundary in DEBUG test processes is narrower and safer than relying on each test to install a hook, while replacing the live SSH child removes the fixed-port and orphan-process hazard without changing production behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a focused native-test reliability and operator-safety cleanup rather than a production runtime regression.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR records an after-fix focused native test run that observed the fail-closed daemon result and no SSH child, alongside a successful Xcode beta build; redact any local paths or identifiers if more terminal output is added.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR records an after-fix focused native test run that observed the fail-closed daemon result and no SSH child, alongside a successful Xcode beta build; redact any local paths or identifiers if more terminal output is added.

Label justifications:

  • P3: This is a focused native-test reliability and operator-safety cleanup rather than a production runtime regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR records an after-fix focused native test run that observed the fail-closed daemon result and no SSH child, alongside a successful Xcode beta build; redact any local paths or identifiers if more terminal output is added.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR records an after-fix focused native test run that observed the fail-closed daemon result and no SSH child, alongside a successful Xcode beta build; redact any local paths or identifiers if more terminal output is added.

Evidence

What I checked:

  • Fail-closed command boundary: The proposed DEBUG-only branch returns an error before resolving or executing the gateway command when a test has not explicitly intercepted daemon calls. (apps/macos/Sources/OpenClaw/GatewayLaunchAgentManager.swift:270, 2c7ed3717646)
  • Test-runner contract coverage: The resolver treats XCTest bundles, XCTest environment variables, and both SwiftPM helper process names as tests; focused tests cover each positive case and a normal application negative case. (apps/macos/Sources/OpenClaw/ProcessInfo+OpenClaw.swift:37, 2c7ed3717646)
  • Deterministic replacement for live SSH child: The PR removes the test that spawned an orphaned SSH process on a fixed port and retains process-info coverage through a local current-process probe plus the adjacent synthetic matrix described in the PR. (apps/macos/Tests/OpenClawIPCTests/LowCoverageHelperTests.swift:337, 2c7ed3717646)
  • After-fix native proof: The PR body reports a successful full Xcode beta build and a focused Swift Testing run with 31 passing tests, the fail-closed error observed, and no SSH child launched; the supplied check context also shows the Real behavior proof check succeeded. (2c7ed3717646)
  • Review limitation: The read-only command sandbox failed before repository history and scoped-file inspection could run, so ownership routing is deliberately low-confidence and no close/implemented-on-main conclusion is proposed.

Likely related people:

  • steipete: The supplied PR metadata identifies steipete as the author of the focused macOS launch-agent and test-isolation change; repository-history inspection was unavailable in the read-only sandbox. (role: recent area contributor; confidence: low; commits: 2c7ed3717646; files: apps/macos/Sources/OpenClaw/GatewayLaunchAgentManager.swift, apps/macos/Sources/OpenClaw/ProcessInfo+OpenClaw.swift)

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 force-pushed the steipete/test-macos-process-isolation branch from 2c7ed37 to e1a07ff Compare July 24, 2026 14:24
@steipete steipete self-assigned this Jul 28, 2026
@steipete
steipete merged commit 5d1311c into main Jul 28, 2026
49 checks passed
@steipete
steipete deleted the steipete/test-macos-process-isolation branch July 28, 2026 17:21
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Jul 28, 2026
…224005-host

* origin/main: (72 commits)
  fix: macOS-only Parallels smoke harness regression (#75293)
  fix(ios): use configured speech language for system voice (#113372)
  refactor: centralize isolated agent test ownership (#115340)
  test(ui): stabilize browser route readiness (#115320)
  fix(cron): clear automation after failed scheduler shutdown (#115316)
  fix: keep isolated gateway workspaces and skills inside state dir (#114487)
  docs: document local TTS on macOS, Linux, and Windows (#110230)
  fix(tasks): clone only the requested task page (#114277)
  fix(agents): prevent Code Mode resume loss and unbounded preparation (#115314)
  fix(process): preserve the first process cancellation reason (#115317)
  fix(nostr): report unavailable ingress when queue open fails (#115313)
  fix: prevent Slack and Feishu ingress startup leaks (#115295)
  fix(slack): avoid unsafe emphasis boundaries (#111575)
  fix: prevent changed checks from expanding into full lint (#115322)
  fix(codex): stabilize prompts and expose real cache regressions (#115238)
  refactor(ui): derive page route specs from the route table (#115214)
  fix(compaction): plan cut points in trigger units (#111886) (#115309)
  fix: prevent cron and gateway stress-run timeouts (#115241)
  fix(ci): validate frozen Matrix QA targets (#115298)
  test(macos): block real process fallthrough (#113337)
  ...

# Conflicts:
#	CHANGELOG.md
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 29, 2026
* test(macos): block real process fallthrough

* test(macos): cover SwiftPM helper executable paths

Co-authored-by: Peter Steinberger <[email protected]>

* test(macos): avoid process-age timing assumption

Co-authored-by: Peter Steinberger <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 29, 2026
…afea23-host

* origin/main: (72 commits)
  fix: macOS-only Parallels smoke harness regression (openclaw#75293)
  fix(ios): use configured speech language for system voice (openclaw#113372)
  refactor: centralize isolated agent test ownership (openclaw#115340)
  test(ui): stabilize browser route readiness (openclaw#115320)
  fix(cron): clear automation after failed scheduler shutdown (openclaw#115316)
  fix: keep isolated gateway workspaces and skills inside state dir (openclaw#114487)
  docs: document local TTS on macOS, Linux, and Windows (openclaw#110230)
  fix(tasks): clone only the requested task page (openclaw#114277)
  fix(agents): prevent Code Mode resume loss and unbounded preparation (openclaw#115314)
  fix(process): preserve the first process cancellation reason (openclaw#115317)
  fix(nostr): report unavailable ingress when queue open fails (openclaw#115313)
  fix: prevent Slack and Feishu ingress startup leaks (openclaw#115295)
  fix(slack): avoid unsafe emphasis boundaries (openclaw#111575)
  fix: prevent changed checks from expanding into full lint (openclaw#115322)
  fix(codex): stabilize prompts and expose real cache regressions (openclaw#115238)
  refactor(ui): derive page route specs from the route table (openclaw#115214)
  fix(compaction): plan cut points in trigger units (openclaw#111886) (openclaw#115309)
  fix: prevent cron and gateway stress-run timeouts (openclaw#115241)
  fix(ci): validate frozen Matrix QA targets (openclaw#115298)
  test(macos): block real process fallthrough (openclaw#113337)
  ...

# Conflicts:
#	CHANGELOG.md
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 P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

1 participant