What this thread does
sandbox-exec: sandbox_apply: Operation not permitted — inspect Codex's effective permissions before changing Swift code.
A denied helper can appear as an Observation macro implementation error, alongside separate CoreSimulator connection errors (public reproduction).
Do first: record the active sandbox, approval policy and writable roots; run xcrun simctl list devices available to isolate service access from project compilation.
Not for: signing/provisioning errors, Xcode project-file serialization, or Docker volume ownership errors from PostgreSQL.
Diagnose the boundary first
1. Read the effective task policy, including managed restrictions. approval_policy = "never" suppresses approval prompts; it does not grant filesystem, network or service access. Admin requirements can constrain settings users cannot override. If escalation is unavailable, have the operator run the exact validation in an authorized environment and return its log; changing user configuration cannot override managed requirements (sandbox controls, requirements reference). 2. Record xcodebuild -version and xcode-select -p, then compare the same failing command in the restricted task and an operator's normal terminal. A permission explanation is stronger when only the restricted invocation fails; a failure in both also needs ordinary Xcode/service investigation. Apple's command-line FAQ explains tool selection; SwiftedMind's report shows even xcodebuild -list reaching CoreSimulator and cache paths. 3. Use a distinct writable DerivedData/module-cache directory for the probe. This addresses file placement only: the macro reproduction still failed with a module cache under /tmp (AUsernameForYou). Do not interpret cache relocation as permission to contact system services.
Diagnostic: sandbox-exec: sandbox_apply: Operation not permitted
To isolate macro expansion, save this as .validation/PermissionProbe.swift under your project, create .validation/ModuleCache, and run:
import Observation
@Observable final class PermissionProbe { var count = 0 }
xcrun swiftc -typecheck -module-cache-path .validation/ModuleCache .validation/PermissionProbe.swift
If the helper denial accompanies the missing Observation macro implementation, retain both messages. In AUsernameForYou's 2026-10-16 report, this combination occurred on macOS 26.5.2/Xcode 26.6. It is evidence to investigate process restrictions before rewriting @Observable; it does not establish that every missing-macro error has that cause.
Diagnostic: CoreSimulatorService connection became invalid.
Run xcrun simctl list devices available independently of the project. SwiftedMind, 2025-10-09, reported this error together with denied cache/log access. Record the first fatal build step, not just the exit code.
For a compilation-only probe, substitute your actual project and shared scheme, and use a fresh writable output path:
xcodebuild -project App.xcodeproj -scheme App -configuration Debug -destination 'generic/platform=iOS Simulator' -derivedDataPath .validation/Debug build
xcodebuild -project App.xcodeproj -scheme App -configuration Release -destination 'generic/platform=iOS Simulator' -derivedDataPath .validation/Release build
These are proposed build probes, not a promise of service-free compilation. The 2026-10-16 reproduction reports an unsigned generic-device build failing in asset compilation when simulator runtimes were unavailable to the task. A successful build establishes compilation for that configuration; build-for-testing builds test products; running XCTest/XCUITest requires a test action and an executable destination (Apple's action definitions).
Diagnostic: FATAL: could not create shared memory segment: Operation not permitted
For PostgreSQL initdb, preserve the following DETAIL line too. A denied shmget(...) identifies an IPC problem to investigate; a directory/chmod error identifies a different path. Initialize only a fresh disposable directory owned by the intended server user; initdb creates a cluster and refuses root (PostgreSQL initdb).
Do not assume a writable data directory or dynamic_shared_memory_type=mmap removes all System V requirements: PostgreSQL documents a small System V segment separately from the main anonymous mapping (kernel resources). Thomas Munro, 2025-09-10, discusses Wolfgang Walther's 2025-09-09 Nix/macOS report of this denial. That is a related Darwin sandbox case, not a Codex-specific reproduction.
If cluster startup is blocked, label SQL-recorder assertions as query-construction evidence only. Drizzle's .toSQL() can expose SQL and parameters without executing the query. For an existing builder, compare against independently specified expectations using Vitest equality matchers:
const { sql, params } = query.toSQL();
expect(sql).toBe(expectedSql);
expect(params).toEqual(expectedParams);
Keep identifier double quotes and placeholders in the expected SQL; compare bound values separately instead of interpolating them into the string. Transaction contention, rollback and optimistic-concurrency behavior still need actual PostgreSQL sessions: the database's concurrency-control documentation describes the behavior a recorder does not execute.
Evidence and limits
The two Codex reports have different authors and dates; they are user observations, not a support matrix. The 2026 report describes a suspected UI/effective-policy mismatch, not a proven Full Access defect. The PostgreSQL report concerns Nix, so check the actual failing syscall before transferring its diagnosis. A generic build, a source-only check and a SQL recorder each leave runtime evidence outstanding.
Started from a post by @editor, packaged by the editor. Original post