Skip to content

Fix Linux posix_spawn compatibility - #2531

Merged
steipete merged 2 commits into
steipete:mainfrom
kocaemre:fix/linux-posix-spawn-compat
Aug 2, 2026
Merged

Fix Linux posix_spawn compatibility#2531
steipete merged 2 commits into
steipete:mainfrom
kocaemre:fix/linux-posix-spawn-compat

Conversation

@kocaemre

Copy link
Copy Markdown
Contributor

Summary

  • Adds a small Linux compatibility shim for posix_spawn_file_actions_addchdir_np and posix_spawn_file_actions_addclosefrom_np.
  • Routes the PTY/process launchers through that shim so the Linux Swift target builds when Swift's Glibc module does not declare those GNU extensions.
  • Leaves the existing Darwin and Musl code paths unchanged.

Why

On Ubuntu 22.04 with Swift 6.2, swift test list failed during compilation because the symbols exist in glibc but are not exposed by Swift's Glibc module:

cannot find 'posix_spawn_file_actions_addchdir_np' in scope
cannot find 'posix_spawn_file_actions_addclosefrom_np' in scope

The new declarations are limited to the Glibc build and keep the existing runtime behavior.

Testing

  • PATH=/opt/swift-6.2/usr/bin:$PATH swift test list
  • PATH=/opt/swift-6.2/usr/bin:$PATH swift build
  • PATH=/opt/swift-6.2/usr/bin:$PATH ./Scripts/test.sh
  • git diff --check
  • PATH=/opt/swift-6.2/usr/bin:$PATH .build/lint-tools/bin/swiftformat Sources/CodexBarCore/Host/Process/PosixSpawnFileActionsCompatibility.swift Sources/CodexBarCore/Host/Process/PosixSpawnFileActionsCloseFrom.swift Sources/CodexBarCore/Host/Process/SpawnedProcessGroup.swift Sources/CodexBarCore/Providers/Antigravity/AntigravityCLISession.swift --lint

Note: I also ran make check; its portable checks passed, but the full command stopped in repository-wide SwiftFormat lint with pre-existing enumNamespaces timeouts in unrelated provider files before SwiftLint ran.

Signed-off-by: Emre Koca <110906681+kocaemre@users.noreply.github.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c9f6e754c4

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".


enum PosixSpawnFileActionsCompatibility {
static func addChangeDirectory(
_ fileActions: inout posix_spawn_file_actions_t,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Accept Darwin's optional file-action handle

On Darwin, the call sites in this commit still declare fileActions as posix_spawn_file_actions_t?, matching the imported posix_spawn_file_actions_* APIs for the opaque spawn handle. This wrapper now requires a non-optional inout posix_spawn_file_actions_t, so macOS builds hit an inout optional/non-optional mismatch at the changed addChangeDirectory(&fileActions, ...) calls even though the old direct C calls compiled; add a Darwin-specific overload/typealias that accepts the optional handle.

Useful? React with 👍 / 👎.

@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. P1 Urgent regression or broken agent/channel workflow affecting real users now. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. labels Jul 31, 2026
@clawsweeper

clawsweeper Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 7:42 AM ET / 11:42 UTC.

ClawSweeper review

What this changes

The PR adds a Glibc declaration shim for two GNU posix_spawn file-action APIs and routes CodexBar’s process and PTY launchers through it so Linux Swift 6.2 builds compile.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

This remains necessary: current main still directly references the GNU spawn extensions that Swift 6.2 does not import on Glibc. The revised PR fixes the earlier Darwin optional-handle mismatch, and the contributor supplied after-fix Ubuntu 22.04 / Swift 6.2 terminal evidence; no correctness finding remains. Keep it open for normal maintainer merge after a macOS compile check confirms the cross-platform wrapper path.

Priority: P1
Reviewed head: 95ff23eff86d75dd1ab58a518e2cc9e39d446af1

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused repair resolves the prior blocking review finding and has credible Linux after-fix terminal proof, with a remaining prudent macOS compatibility confirmation.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The contributor posted redacted terminal output from the revised head showing successful Swift 6.2 Ubuntu 22.04 test discovery, build, and repository test-script runs; this directly demonstrates the reported Linux compilation recovery.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The contributor posted redacted terminal output from the revised head showing successful Swift 6.2 Ubuntu 22.04 test discovery, build, and repository test-script runs; this directly demonstrates the reported Linux compilation recovery.
Evidence reviewed 5 items Current-main behavior: Current main still calls the two GNU POSIX spawn extensions directly at the affected process-launch sites, so the reported missing-Glibc-declaration build failure is not already addressed.
Darwin correction at PR head: The PR head uses a Darwin-specific optional posix_spawn_file_actions_t alias and retains non-optional Glibc/Musl handles, resolving the prior inout type mismatch without changing the Glibc shim path.
Prior finding resolved: The only prior P1 finding targeted the Darwin optional-handle mismatch; the follow-up commit changes exactly that wrapper parameter representation while leaving the Linux declarations intact.
Findings None None.
Security None None.

How this fits together

CodexBar launches local CLI and PTY subprocesses for provider integrations. The launchers assemble POSIX spawn file actions for working-directory and descriptor setup before starting each child process.

flowchart LR
    A[Provider CLI request] --> B[Process or PTY launcher]
    B --> C[POSIX spawn file actions]
    C --> D[Platform compatibility wrapper]
    D --> E[Darwin or Linux C library]
    E --> F[Child process starts]
Loading

Before merge

  • Resolve merge risk (P1) - The changed wrapper is shared by Darwin and Linux launch paths, but the submitted runtime proof covers Linux only; a macOS Swift build should confirm the corrected optional-handle bridge before merge.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Patch scope 4 files affected; 50 added, 3 removed The diff centralizes platform interop in one new wrapper and updates three existing launch paths.

Merge-risk options

Maintainer options:

  1. Confirm the Darwin build (recommended)
    Run a macOS Swift build or focused test at the PR head to confirm the optional spawn-handle bridge, then merge the Linux compiler-compatibility repair.
  2. Accept source-level Darwin proof
    Merge based on the corrected optional alias and existing Linux proof if maintainers consider the existing macOS CI coverage sufficient.

Technical review

Best possible solution:

Merge the narrow wrapper after a macOS build confirms both platform handle representations compile, preserving direct platform behavior while isolating Swift Glibc-import gaps in one place.

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

Yes. Current main directly imports the two GNU extensions that Swift’s Glibc module omits, and the contributor supplied after-fix Swift 6.2 Ubuntu 22.04 build and test output from the revised PR head.

Is this the best way to solve the issue?

Yes. A small typed compatibility wrapper is the narrowest maintainable fix because it preserves existing launcher behavior while isolating only the missing Glibc declarations.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: Current Linux Swift 6.2 builds fail before users can run CodexBar’s command-line and provider process paths.
  • merge-risk: 🚨 compatibility: The patch changes a shared POSIX spawn bridge used on Darwin, Glibc, and Musl builds.
  • 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 (terminal): The contributor posted redacted terminal output from the revised head showing successful Swift 6.2 Ubuntu 22.04 test discovery, build, and repository test-script runs; this directly demonstrates the reported Linux compilation recovery.
  • proof: sufficient: Contributor real behavior proof is sufficient. The contributor posted redacted terminal output from the revised head showing successful Swift 6.2 Ubuntu 22.04 test discovery, build, and repository test-script runs; this directly demonstrates the reported Linux compilation recovery.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Current-main history for the affected POSIX spawn call path resolves to Peter Steinberger’s commit; the checkout could not complete older promisor-history retrieval for stronger introducer attribution. (role: current-main area contributor; confidence: medium; commits: b1170d83963d; files: Sources/CodexBarCore/Host/Process/SpawnedProcessGroup.swift, Sources/CodexBarCore/Host/Process/PosixSpawnFileActionsCloseFrom.swift, Sources/CodexBarCore/Providers/Antigravity/AntigravityCLISession.swift)

Rank-up moves

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

  • Run or confirm a macOS Swift build at the current PR head before merging the shared platform wrapper.

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 (2 earlier review cycles)
  • reviewed 2026-07-31T16:25:39.903Z sha c9f6e75 :: needs real behavior proof before merge. :: [P1] Accept Darwin’s optional file-action handle
  • reviewed 2026-07-31T23:02:11.903Z sha c9f6e75 :: needs real behavior proof before merge. :: [P1] Accept Darwin’s optional file-action handle

@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 31, 2026
Signed-off-by: Emre Koca <110906681+kocaemre@users.noreply.github.com>
@kocaemre

kocaemre commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

I pushed 95ff23eff86d75dd1ab58a518e2cc9e39d446af1 to address the Darwin handle mismatch flagged in review.

What changed:

  • Added a platform-specific PosixSpawnFileActionsHandle alias.
  • Darwin now keeps the imported optional posix_spawn_file_actions_t? representation for wrapper call sites.
  • Glibc/Musl continue using non-optional posix_spawn_file_actions_t, so the Linux shim path is unchanged.

Linux verification from Ubuntu 22.04 / Swift 6.2:

$ PATH=/opt/swift-6.2/usr/bin:$PATH swift test list
...
CodexBarLinuxTests.ZaiUsedPercentLinuxTests/`computed path takes precedence and ignores the raw percentage`()
CodexBarLinuxTests.ZaiUsedPercentLinuxTests/`raw percentage fallback clamps above 100`()
CodexBarLinuxTests.ZaiUsedPercentLinuxTests/`raw percentage fallback clamps below 0`()
CodexBarLinuxTests.ZaiUsedPercentLinuxTests/`raw percentage fallback preserves an in-range value`()
$ PATH=/opt/swift-6.2/usr/bin:$PATH swift build
warning: 'codexbar': dependency 'sparkle' is not used by any target
warning: 'codexbar': dependency 'keyboardshortcuts' is not used by any target
warning: 'codexbar': dependency 'vortex' is not used by any target
[0/1] Planning build
Building for debugging...
[0/4] Write swift-version--DC8D11E1D585A92.txt
Build complete! (7.27s)
$ PATH=/opt/swift-6.2/usr/bin:$PATH ./Scripts/test.sh
Swift test timing summary:
- Shard: none
- Group size: 12
- Discovered selections: 48
- Selected selections: 48
- Selected groups: 4
- First-pass successful groups: 4
- First-pass failed groups: 0
- Full-group retries: 0
- Recovered groups: 0
- Timed out groups: 0
- Isolated selection retries: 0
- Discovery seconds: 8.6
- Execution seconds: 9.5
- Total seconds: 18.2
$ git diff --check
# no output
$ PATH=/opt/swift-6.2/usr/bin:$PATH .build/lint-tools/bin/swiftformat \
  Sources/CodexBarCore/Host/Process/PosixSpawnFileActionsCompatibility.swift \
  Sources/CodexBarCore/Host/Process/PosixSpawnFileActionsCloseFrom.swift \
  Sources/CodexBarCore/Host/Process/SpawnedProcessGroup.swift \
  Sources/CodexBarCore/Providers/Antigravity/AntigravityCLISession.swift --lint
Running SwiftFormat...
(lint mode - no files will be changed.)
Reading config file at /root/oss/CodexBar/.swiftformat
SwiftFormat completed in 0.26s.
0/4 files require formatting.

Boundary note: I also re-ran make check. Its portable checks passed, then repo-wide SwiftFormat stopped on existing timeouts in unrelated files:

error: enumNamespaces rule timed out in Sources/CodexBarCore/Providers/Providers.swift.
error: enumNamespaces rule timed out in Sources/CodexBarCore/Providers/Antigravity/AntigravityQuotaSummaryParser.swift.
error: wrap rule timed out in Sources/CodexBarCore/Providers/Alibaba/AlibabaTokenPlanUsageFetcher.swift.
error: enumNamespaces rule timed out in Sources/CodexBarCore/Providers/OpenCodeGo/OpenCodeGoUsageFetcher.swift.
make: *** [Makefile:22: check] Error 70

@clawsweeper

clawsweeper Bot commented Aug 1, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
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 proof: sufficient Contributor real behavior proof is sufficient. 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. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 1, 2026
@steipete
steipete merged commit e0b3d50 into steipete:main Aug 2, 2026
9 checks passed
steipete pushed a commit that referenced this pull request Aug 2, 2026
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P1 Urgent regression or broken agent/channel workflow affecting real users now. proof: sufficient Contributor real behavior proof is sufficient. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants