Skip to content

simcamctl feed: bound the camera prompt wait, check device first, use exit 1 for runtime errors - #15

Merged
dautovri merged 1 commit into
mainfrom
fix/simcamctl-feed-hardening
Oct 21, 2026
Merged

dautovri merged 1 commit into
mainfrom
fix/simcamctl-feed-hardening

Conversation

@dautovri

Copy link
Copy Markdown
Owner

What

Follow-up to PR 14, from a Gemini 4 review of that change (each finding checked against the code before fixing). All changes are in simcamctl/FeedCommand.swift.

  • Bounded prompt wait. The camera-access prompt wait now times out after 60s with a clear error. Before, an unattended run (script, CI, ssh into a logged-in Mac) blocked forever, because the --seconds timer only starts after capture setup.
  • Device check first. Look for camera hardware before requesting access, so a Mac with no camera reports "no Mac camera available" instead of prompting for a permission it can't use.
  • Exit codes. Runtime failures in feed exit 1 (generic error). Exit 3 stays reserved for invalid arguments, as documented in the help text.
  • .restricted message. A camera restricted by Screen Time or a profile gets its own message, since the System Settings instruction can't be followed there.
  • Frame counter. written is guarded by an OSAllocatedUnfairLock: the capture queue increments it while the timer queue and finish() read it. This was a latent data race that only matters now that --camera actually delivers frames.
  • Also dropped the nonisolated(unsafe) variable: success is read from the authorization status after the prompt.

Tested

  • Build succeeds; the 20 contract tests pass (CI-style, unsigned).
  • simcamctl feed --camera --seconds 4 wrote 86 frames.
  • feed --image /nonexistent.png exits 1; feed with no source exits 3.

Not tested

  • Camera denied, restricted, and prompt-timeout paths (would require resetting the terminal's camera permission or changing Screen Time).
  • No-camera hardware path.

🤖 Generated with Claude Code

… exit 1 for runtime errors

Follow-up to PR 14 from a Gemini 4 review. Time out the TCC prompt wait after 60s instead of blocking forever in unattended runs. Look for camera hardware before requesting access so a Mac without a camera reports that. Exit 1 (generic error) for runtime failures; exit 3 stays reserved for invalid arguments. Give .restricted its own message since System Settings cannot change it. Guard the frame counter with a lock now that the capture queue and the timer queue both touch it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@dautovri
dautovri merged commit 1991746 into main Oct 21, 2026
2 checks passed
@dautovri
dautovri deleted the fix/simcamctl-feed-hardening branch October 21, 2026 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant