Skip to content

test(macos): cover root command dispatch#93705

Merged
vincentkoc merged 2 commits into
openclaw:mainfrom
markoub:markoub/macos-root-command-tests
Jun 16, 2026
Merged

test(macos): cover root command dispatch#93705
vincentkoc merged 2 commits into
openclaw:mainfrom
markoub:markoub/macos-root-command-tests

Conversation

@markoub

@markoub markoub commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds focused regression coverage for the macOS openclaw-mac root command parser and dispatch decision.
  • Extracts the root dispatch decision into an internal RootCommandAction helper so the behavior can be tested without spawning a process or intercepting exit(1).
  • Keeps the runtime dispatch behavior equivalent to the existing entry point: help and empty args print usage, known commands receive trailing args, and unknown commands exit nonzero.
  • Intentionally does not change any command-specific option parsing or runtime behavior.
  • AI-assisted: yes. I understand the code path and verified the focused macOS Swift tests locally.

Linked context

Closes #83879

Related #83879

Was this requested by a maintainer or owner?

  • No direct maintainer request; this addresses an open ClawSweeper-triaged test-gap issue.

Real behavior proof (required for external PRs)

  • Behavior or issue addressed: No tests cover parseRootCommand or the command-dispatch switch in main() #83879 reported that parseRootCommand and the root command-dispatch switch in OpenClawMacCLI.main() had no focused tests.
  • Real environment tested: Local macOS source checkout on arm64e, Swift Package Manager via swift test --package-path apps/macos --filter RootCommandParserTests.
  • Exact steps or command run after this patch: swift test --package-path apps/macos --filter RootCommandParserTests
  • Evidence after fix (screenshot, recording, terminal capture, console output, redacted runtime log, linked artifact, or copied live output): terminal output copied from the local macOS run after this patch:
Building for debugging...
[0/6] Write swift-version--58304C5D6DBC2206.txt
Build complete! (0.32s)
Test Suite 'Selected tests' started at 2026-06-16 18:29:34.084.
Test Suite 'OpenClawPackageTests.xctest' started at 2026-06-16 18:29:34.085.
Test Suite 'OpenClawPackageTests.xctest' passed at 2026-06-16 18:29:34.085.
         Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.000) seconds
Test Suite 'Selected tests' passed at 2026-06-16 18:29:34.085.
         Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.001) seconds
◇ Test run started.
↳ Testing Library Version: 1743
↳ Target Platform: arm64e-apple-macos14.0
◇ Suite RootCommandParserTests started.
◇ Test "help aliases resolve to usage" started.
◇ Test "parse root command returns nil for empty args" started.
◇ Test "known commands preserve trailing args" started.
◇ Test "command names remain case sensitive" started.
◇ Test "parse root command splits command name and args" started.
◇ Test "unknown command resolves to nonzero exit action" started.
✔ Test "parse root command returns nil for empty args" passed after 0.001 seconds.
✔ Test "help aliases resolve to usage" passed after 0.001 seconds.
✔ Test "parse root command splits command name and args" passed after 0.001 seconds.
✔ Test "unknown command resolves to nonzero exit action" passed after 0.001 seconds.
✔ Test "command names remain case sensitive" passed after 0.001 seconds.
✔ Test "known commands preserve trailing args" passed after 0.001 seconds.
✔ Suite RootCommandParserTests passed after 0.001 seconds.
✔ Test run with 6 tests in 1 suite passed after 0.001 seconds.
  • Observed result after fix: The new tests cover empty args, command/argument splitting, help aliases, all known root commands preserving trailing args, unknown command resolving to exit code 1, and case-sensitive command names.
  • What was not tested: I did not run the built openclaw-mac executable manually, and I did not validate command-specific option parsing beyond preserving the trailing args handed to each command.
  • Proof limitations or environment constraints: swift test --package-path apps/macos --filter OpenClawIPCTests currently fails in unrelated ExecApprovalsStoreRefactorTests.ensure file migrates default approvals into custom state dir expectations; the new RootCommandParserTests pass in that broader run before the unrelated suite failure.
  • Before evidence (optional but encouraged): Before this patch, there was no test file covering EntryPoint.swift, and parseRootCommand was private to the entry point.

Tests and validation

  • swift test --package-path apps/macos --filter RootCommandParserTests passed.
  • git diff --check origin/main...HEAD passed.
  • codex review --base origin/main reported no actionable correctness issues and confirmed dispatch behavior appears equivalent to the base implementation.
  • swift test --package-path apps/macos --filter OpenClawIPCTests failed due an unrelated existing ExecApprovalsStoreRefactorTests migration expectation, not in files touched by this PR.

Regression coverage added:

Risk checklist

Did user-visible behavior change? (Yes/No)

  • No.

Did config, environment, or migration behavior change? (Yes/No)

  • No.

Did security, auth, secrets, network, or tool execution behavior change? (Yes/No)

  • No.

What is the highest-risk area?

  • Accidentally changing root command dispatch while extracting it for tests.

How is that risk mitigated?

  • The new RootCommandAction mapping mirrors the previous switch cases, and the focused tests assert the existing behavior for empty args, help aliases, known commands, unknown command exit action, and case sensitivity.

Current review state

What is the next action?

  • Draft PR for maintainer/user review and CI.

What is still waiting on author, maintainer, CI, or external proof?

  • Waiting on CI and human review.

Which bot or reviewer comments were addressed?

  • Real behavior proof bot rejected the initial inline evidence as insufficient. This body now includes copied terminal output from the local after-patch run.

@openclaw-barnacle openclaw-barnacle Bot added triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. app: macos App: macos size: S proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 16, 2026
@clawsweeper

clawsweeper Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed June 16, 2026, 1:52 PM ET / 17:52 UTC.

Summary
The PR extracts macOS root command dispatch into a testable Swift helper and adds focused parser/dispatch tests.

PR surface: Other +66. Total +66 across 2 files.

Reproducibility: yes. Current-main source inspection shows the private parser and root dispatch switch with no focused root parser/action tests, and the live macos-swift check reproduces the submitted patch's formatting failure.

Review metrics: none identified.

Root-cause cluster
Relationship: same_root_cause
Canonical: #83879
Summary: This PR and the overlapping open PR both address the same canonical macOS root command parser/dispatch test-gap issue.

Members:

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

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🐚 platinum hermit
Patch quality: 🦪 silver shellfish
Result: blocked by patch quality or review findings.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Apply SwiftFormat to apps/macos/Sources/OpenClawMacCLI/EntryPoint.swift and rerun the focused parser test or macos-swift lane.

Risk before merge

  • [P1] The live macos-swift lane is red until EntryPoint.swift is formatted with the repo SwiftFormat rules.
  • [P1] test(macos): cover root CLI command parsing #93188 is another open candidate for the same linked issue, so maintainers should land one path and avoid duplicate coverage work.

Maintainer options:

  1. Decide the mitigation before merge
    Land a single narrow root parser/dispatch coverage path after SwiftFormat passes; if the overlapping PR becomes the chosen path, close or retarget this PR after that path merges.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P2] A narrow mechanical SwiftFormat repair in the changed entrypoint should make the branch reviewable without a product or ownership decision.

Security
Cleared: No security or supply-chain concern was found; the diff is limited to Swift source/test coverage and does not change dependencies, workflows, secrets, auth, or package resolution.

Review findings

  • [P2] Run SwiftFormat on EntryPoint.swift — apps/macos/Sources/OpenClawMacCLI/EntryPoint.swift:24
Review details

Best possible solution:

Land a single narrow root parser/dispatch coverage path after SwiftFormat passes; if the overlapping PR becomes the chosen path, close or retarget this PR after that path merges.

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

Yes. Current-main source inspection shows the private parser and root dispatch switch with no focused root parser/action tests, and the live macos-swift check reproduces the submitted patch's formatting failure.

Is this the best way to solve the issue?

No as submitted. The helper-and-tests approach is a narrow maintainable fix, but the branch needs SwiftFormat repair before it is a mergeable solution.

Full review comments:

  • [P2] Run SwiftFormat on EntryPoint.swift — apps/macos/Sources/OpenClawMacCLI/EntryPoint.swift:24
    The live macos-swift job fails swiftformat --lint on this changed file, starting with the new case .connect(let commandArgs) pattern style. Until the file is formatted with the repo SwiftFormat rules, the required macOS Swift lane stays red.
    Confidence: 0.95

Overall correctness: patch is incorrect
Overall confidence: 0.9

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add P3: This is a small macOS test-coverage cleanup with a formatting blocker, not a demonstrated user-facing runtime regression.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides copied after-patch macOS terminal output for the focused Swift test run that exercises the new parser/dispatch tests.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🐚 platinum hermit and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (terminal): The PR body provides copied after-patch macOS terminal output for the focused Swift test run that exercises the new parser/dispatch tests.

Label justifications:

  • P3: This is a small macOS test-coverage cleanup with a formatting blocker, not a demonstrated user-facing runtime regression.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🐚 platinum hermit and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (terminal): The PR body provides copied after-patch macOS terminal output for the focused Swift test run that exercises the new parser/dispatch tests.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides copied after-patch macOS terminal output for the focused Swift test run that exercises the new parser/dispatch tests.
Evidence reviewed

PR surface:

Other +66. Total +66 across 2 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 2 83 17 +66
Total 2 83 17 +66

Acceptance criteria:

  • [P1] swiftformat --lint apps/macos/Sources --config config/swiftformat --exclude '/OpenClawProtocol,/HostEnvSecurityPolicy.generated.swift'.
  • [P1] swift test --package-path apps/macos --filter RootCommandParserTests.

What I checked:

Likely related people:

  • steipete: Git history shows Peter Steinberger introduced the renamed EntryPoint.swift root parser/dispatch file and has the strongest macOS CLI/package history in this area. (role: prior root-command introducer and macOS CLI area contributor; confidence: high; commits: 9a7160786a7d, 4999f15688b1, a70d9beb3a9d; files: apps/macos/Sources/OpenClawMacCLI/EntryPoint.swift, apps/macos/Package.swift)
  • ngutman: Git history shows Nimrod Gutman worked on nearby macOS gateway/config and test surfaces, making him a reasonable secondary routing candidate for the surrounding macOS test target. (role: adjacent macOS CLI and test contributor; confidence: medium; commits: c4a4050ce48b, 144c1b802bf6, 3d3e8fe78c91; files: apps/macos/Tests/OpenClawIPCTests, apps/macos/Sources/OpenClawMacCLI)
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.

@markoub
markoub marked this pull request as ready for review June 16, 2026 17:24
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jun 16, 2026
@vincentkoc vincentkoc self-assigned this Jun 16, 2026
@vincentkoc
vincentkoc force-pushed the markoub/macos-root-command-tests branch from cc869d7 to 7818029 Compare June 16, 2026 18:33
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 16, 2026
@vincentkoc

Copy link
Copy Markdown
Member

Maintainer repair and verification complete.

  • Formatted the new macOS CLI seam and tests with the repository SwiftFormat configuration
  • swiftformat --lint apps/macos/Sources --config config/swiftformat --exclude '**/OpenClawProtocol,**/HostEnvSecurityPolicy.generated.swift' passed
  • swift test --package-path apps/macos --filter RootCommandParserTests was attempted but blocked before these tests by the cached swiftui-math external macro implementation not being available
  • Fresh autoreview after the repair: clean
  • Rebased onto current main and pushed to the contributor branch

@vincentkoc
vincentkoc merged commit b9e193c into openclaw:main Jun 16, 2026
39 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 17, 2026
* test(macos): cover root command dispatch

* chore(macos): format root command coverage

---------

Co-authored-by: markoub <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
crh-code pushed a commit to crh-code/openclaw that referenced this pull request Jun 18, 2026
* test(macos): cover root command dispatch

* chore(macos): format root command coverage

---------

Co-authored-by: markoub <[email protected]>
Co-authored-by: Vincent Koc <[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 P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S 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.

No tests cover parseRootCommand or the command-dispatch switch in main()

2 participants