Skip to content

fix: verify and retry stapling so --notarize can't falsely report success - #100

Closed
yepzdk-bot wants to merge 1 commit into
mainfrom
feature/issue-004-staple-validation
Closed

fix: verify and retry stapling so --notarize can't falsely report success#100
yepzdk-bot wants to merge 1 commit into
mainfrom
feature/issue-004-staple-validation

Conversation

@yepzdk-bot

Copy link
Copy Markdown
Collaborator

Summary

update/create with --notarize could report success even when the notary ticket wasn't actually stapled: stapling ran once with its output suppressed (quiet: true) and no verification, so stapler staple exiting 0 without attaching a ticket left apps "notarized" but unstapled while the CLI happily reported success.

This reworks AppBuilder.notarizeAndStaple to prevent that silent failure:

  • Retry with backoff — a freshly-accepted ticket can lag behind acceptance on Apple's CDN, so stapling now retries up to stapleAttempts times, waiting a growing stapleBackoff between tries.
  • Validate before success — after stapler staple exits 0, the CLI runs xcrun stapler validate and only reports success if the ticket is genuinely attached.
  • Surface the real output — stapling now runs via runCapturingAll (not quiet: true), so the stapler's own output is shown rather than suppressed.
  • Actionable failure — on exhaustion it throws with a message stating the app is notarized but not stapled (still passes Gatekeeper online, not offline) and gives the manual xcrun stapler staple "<app>" recovery command.

Acceptance criteria

  • Attempts to staple multiple times with a delay between attempts.
  • Runs xcrun stapler validate to confirm the ticket before reporting success.
  • Displays the actual stapler output on failure instead of suppressing it.
  • Failed stapling errors state the app is notarized but not stapled, with the manual command.

Testing

Pure logic (stapleBackoff, notStapledMessage, stapleAttempts) is unit-tested in StaplingTests.swift, following the repo's pure-vs-side-effect split. The sleep/process orchestration is verified by hand (macOS-only; no Swift toolchain on the CI-less Linux dev host used here).

Closes #WEBWRAP-004

🤖 Generated with Claude Code

…cess

Stapling previously ran once with output suppressed and no verification, so
`stapler staple` exiting 0 without attaching a ticket left apps "notarized"
but unstapled while the CLI reported success.

Now stapling retries with a backoff (the ticket can lag behind acceptance),
confirms the ticket is attached with `xcrun stapler validate` before reporting
success, and on exhaustion throws with the stapler's own output plus the manual
`xcrun stapler staple` recovery command, stating the app is notarized but not
stapled.

Spec: WEBWRAP-004

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@yepzdk yepzdk closed this Aug 25, 2026
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.

2 participants