agent-orchestrator icon indicating copy to clipboard operation
agent-orchestrator copied to clipboard

Long-term fix for #3034: replace maker-zip with ditto-based mac packaging

Open anmol0b opened this issue 4 months ago • 4 comments

Context

Follow-up to #3034. # ships the short-term fix (skip the .blockmap sidecar for macOS zips, forcing full downloads instead of a corrupted differential update). This issue tracks the actual root-cause fix: the macOS zip artifact itself is built in a format Squirrel.Mac's ditto-based install step doesn't fully support.

Root cause (from #3034)

@electron-forge/maker-zip uses a pure-JS zip writer that never produces AppleDouble (._*) companion files or preserves extended attributes/resource forks — unlike electron-builder, which uses macOS's native ditto to build its zips. Squirrel.Mac's ShipIt install step shells out to ditto to extract updates, and ditto expects those companion entries to exist next to their real files. Their absence is the likely cause of the ditto: ... No such file or directory errors in #3034.

Proposed direction

Replace @electron-forge/maker-zip for the darwin target with a maker that produces a zip via the same mechanism electron-builder uses, so the artifact format matches what Squirrel.Mac already knows how to extract.

Two possible approaches, in order of preference:

  1. Delegate to app-builder-lib (electron-builder's internals), mirroring the existing pattern in makers/maker-nsis.ts, which already calls app-builder-lib's buildForge rather than hand-rolling NSIS invocation. Needs research: does app-builder-lib expose a usable mac zip target that internally uses ditto? If so, this is the lower-risk option — it reuses code this project already trusts for Windows packaging, and may make it possible to safely re-enable blockmap differential updates for mac (currently disabled by #), since electron-builder's own blockmap generator (blockmap.mjs already reaches into it) is designed for its own zip format.

  2. Hand-roll a ditto-based maker (execFileSync("ditto", ["-c", "-k", "--keepParent", ...])), if app-builder-lib doesn't expose a suitable target. Higher risk: reimplements packaging logic instead of delegating to a proven library, and needs careful flag selection (--keepParent, no --sequesterRsrc, so AppleDouble entries land inline next to their real files — matching the layout in the reported ditto errors — rather than in a separate __MACOSX/ folder).

Why this needs to be a separate PR/issue from the short-term fix

  • Touches forge.config.ts and the actual release artifact every macOS user downloads — much higher blast radius than the short-term feed-generation change.
  • Cannot be verified without a real macOS build → sign → notarize → publish → auto-update cycle. Local vitest runs can confirm a maker produces a zip, but not that Squirrel.Mac's ShipIt step correctly extracts and installs it end-to-end.
  • May interact with codesigning/notarization (osxSign/osxNotarize in forge.config.ts) in ways that need real verification, even though switching zip tools shouldn't change what's inside the signed .app bundle itself.

What's needed to close this

  • [ ] Research whether app-builder-lib exposes a usable mac zip target (approach 1)
  • [ ] Prototype maker (either approach), with unit tests mirroring makers/maker-nsis.test.ts's style (mock the underlying build call, assert on invocation args/output path)
  • [ ] Real macOS packaging run confirming the zip contains expected AppleDouble entries (unzip -l / manual inspection)
  • [ ] Real signed build + publish + auto-update verification that a client successfully installs an update built this way
  • [ ] Decision on whether to re-enable blockmap differential updates for mac once the format is confirmed compatible, or leave the short-term full-download behavior in place indefinitely

Related

  • #3034 (original bug report)
  • #3151 (short-term fix, merged/pending)

anmol0b avatar Jul 27 '26 02:07 anmol0b

Thanks for contributing to Agent Orchestrator.

This issue is being picked up by the current external contributor on-call pair:

  • @illegalcall
  • @pulkit7070

If someone is already working on this, please continue as usual. The on-call pair is added for visibility, tracking, and support, not to take over the work. If you need help with review, direction, reproduction, or next steps, please tag @illegalcall and @pulkit7070 here.

For faster context or live questions, you can also join the AO Discord.

Join the session here: https://discord.gg/H6ZDcUXmq

Come by if you want to see what is being built, ask questions, or just hang around with the community.

somewherelostt avatar Jul 27 '26 15:07 somewherelostt

One data point for the checklist item about interaction with codesigning and notarization, plus a scope clarification.

The zip format change will not affect notarization. The stapled ticket lives at Contents/CodeResources inside the bundle as a regular 1968-byte file, not in an extended attribute. The missing AppleDouble entries and lost xattrs that break ShipIt therefore cannot strip it. Moving to a ditto-based maker looks safe from a notarization standpoint, so that risk should not block approach 1.

Verified against the published stable and nightly zips (v0.11.0 and v0.11.1 arm64 and x64, plus v0.10.4-nightly.202607280518), each downloaded with curl and extracted with ditto -x -k:

codesign -dvvv     Authority=Developer ID Application: Prateek Karnal (X9LNSP8MC2)
                   flags=0x10000(runtime), Notarization Ticket=stapled
spctl --assess     accepted, source=Notarized Developer ID
syspolicy_check    App passed all pre-distribution checks
codesign --verify --deep --strict   valid on disk, satisfies its Designated Requirement

Framework symlinks survive the round trip as well, so the current maker is not breaking the signature seal on extraction. That matches the finding in https://github.com/untrivial-ai/agent-orchestrator/issues/3034 that the published artifact itself is correct.

Scope clarification. There is a separate first-install failure that this issue does not cover, so the packaging change should not be treated as closing it. On a filtered network a fresh browser download can fail with "cannot be opened because the developer cannot be verified" even though the build is notarized. Chrome sets com.apple.quarantine, which makes Gatekeeper perform an online ticket lookup:

xcrun stapler validate -v
  URL: https://api.apple-cloudkit.com/database/1/com.apple.gk.ticket-delivery/production/public/records/lookup

When a VPN, corporate firewall, or DNS filter blocks that request, macOS shows the same dialog it uses for unsigned malware instead of falling back to the stapled ticket. No ShipIt or blockmap involvement. Workaround is right-click and Open, or xattr -dr com.apple.quarantine. Double-clicking only offers Move to Trash, which is why affected users tend to retry the download rather than report it.

I will open a separate issue for that and link it here.

Pulkit7070 avatar Jul 29 '26 08:07 Pulkit7070

Two corrections to my comment above, one to my own claim and one to the issue's premise. The second changes what this issue should do.

Retracting the cause I described

The scope-clarification paragraph asserted that Gatekeeper performs an online notarization-ticket lookup against api.apple-cloudkit.com at first launch, and that a blocked request explains the "developer cannot be verified" dialog. That is not supported. As pointed out in https://github.com/Untrivial-ai/agent-orchestrator/pull/3261, xcrun stapler validate -v reaching that endpoint is stapler's own validation path, and it performs the lookup whether or not a ticket is already stapled, so it says nothing about the launch check. Stapling exists so first launch works offline. Retracted; the cause of that separate first-install report is unknown and tracked in https://github.com/Untrivial-ai/agent-orchestrator/issues/3260.

The Contents/CodeResources finding stands, and so does the conclusion that the packaging change cannot affect notarization.

app-builder-lib 26.x does not use ditto

This is the part worth acting on. The premise that electron-builder builds mac zips with ditto is not true of the version pinned here.

In app-builder-lib 26.15.3, ArchiveTarget.build sets preserveSymlinks: isMac, which routes mac zips to native zip in out/targets/archive.js:

// macOS native zip: -y preserves symlinks (required for .framework bundles)
const args = ["-q", "-r", "-y"]

grep -rn "ditto" node_modules/app-builder-lib/out/ returns nothing.

So approach 1 as written cannot work: delegating to app-builder-lib produces a zip -y archive, not a ditto archive, and zip writes no AppleDouble entries either.

Measured comparison

I built the same signed bundle three ways and extracted each with ditto, which is what ShipIt does:

method ._* entries __MACOSX signature after extract symlinks daemon/ao
zip -q -r -y -7 (what electron-builder 26.x actually runs) 0 0 valid, ticket stapled 14/14 present
ditto -c -k --keepParent 275 0 valid, ticket stapled 14/14 present
ditto -c -k --sequesterRsrc --keepParent 275 376 valid, ticket stapled 14/14 present

Three consequences:

  1. electron-builder's own mac zip contains zero AppleDouble entries, so "match electron-builder's format" and "preserve AppleDouble" are contradictory goals.
  2. Their absence breaks nothing. The zip -y archive has none and still extracts to a bundle passing codesign --verify --deep --strict with the ticket intact and all 14 framework symlinks preserved.
  3. The bundle carries no resource forks. The xattrs present are com.apple.cs.CodeDirectory / CodeSignature / CodeRequirements on 65 entries, plus com.apple.provenance, which macOS adds locally rather than at build time. The ._* files ditto writes are carriers for those, and the signature validates without them.

A ditto-based maker would add roughly 470 KB of ._* files and change nothing measurable.

What this suggests about #3034

The error output there names ._icon.png__, ._app.asar__, ._electron.icns__. The trailing __ is not a valid AppleDouble filename. Garbled entry names plus one genuinely missing real file (daemon/ao) is what extracting a corrupted archive produces, which is what a bad blockmap differential download yields. That is hypothesis 2 in #3034, and https://github.com/Untrivial-ai/agent-orchestrator/pull/3151 already removes it by forcing full downloads on mac.

Suggestion

Descope or close this in favour of confirming #3151 resolved the reported failure, which needs one real auto-update cycle.

If a maker is still wanted, the version with a rationale is one matching electron-builder's actual output (zip -y, or delegating to ArchiveTarget), on the theory that maker-zip's pure-JS archive differs structurally from what app-builder-lib's blockmap generator expects. That would target safely re-enabling mac differential updates rather than AppleDouble. I have not attempted it, since it cannot be verified without a real sign, publish, and auto-update cycle, and I would rather not put unverified code in the path of every macOS download.

Happy to be wrong on any of this if someone can reproduce the ShipIt failure against a full (non-differential) download. That would put AppleDouble back in play and I would withdraw the suggestion.

Pulkit7070 avatar Jul 29 '26 08:07 Pulkit7070

Superseded by #3267, per that issue's explicit recommendation.

The premise here (electron-builder builds mac zips with ditto, so matching that format fixes #3034) does not hold. Pulkit7070's own follow-up found app-builder-lib 26.15.3 sets preserveSymlinks: isMac and routes mac zips through native zip -q -r -y, not ditto. And the corruption reproduced against a target zip that was already ditto-built with its full AppleDouble set, so the format was never the operative cause.

The real fixes landed elsewhere: #3151 (mac differential updates off permanently), the sidecar sweep, and #3267/#3294 (dmg for first install, which removes the user-driven extraction step entirely).

harshitsinghbhandari avatar Aug 02 '26 17:08 harshitsinghbhandari