Skip to content

Fix macOS E2E bundle source identity - #14308

Merged
kodjima33 merged 1 commit into
BasedHardware:mainfrom
aryanorastar:codex/13126-desktop-build-identity
Sep 18, 2026
Merged

kodjima33 merged 1 commit into
BasedHardware:mainfrom
aryanorastar:codex/13126-desktop-build-identity

Conversation

@aryanorastar

@aryanorastar aryanorastar commented Sep 17, 2026 •

Copy link
Copy Markdown
Collaborator

What changed and why

Closes #13126.

Named macOS bundles now embed a versioned source receipt before codesigning and expose it through the unauthenticated automation /health response. The receipt contains the full source commit and clean/dirty working-tree state; missing, partial, or malformed metadata fails closed as unknown.

The desktop E2E harness now compares that runtime receipt with its own checkout before accepting flow evidence, so a reused pool slot or bundle from another worktree cannot be mistaken for the revision under review. Both full bundle creation and executable-only fast rebuilds refresh the receipt before signing.

Product invariants affected

none

How it was verified

  • bash desktop/macos/tests/test-desktop-build-identity.sh
    • Passed clean, dirty, non-repository/unknown, matching-health, and stale-health rejection cases.
  • bash desktop/macos/tests/test-desktop-core-harness-readiness-teardown.sh
    • Passed all readiness cleanup scenarios after keeping source-receipt loading scoped to live bridge validation.
  • bash desktop/macos/tests/test-fault-suite-launch-env.sh
    • Passed with the hermetic fault bundle emitting and validating a revision-specific source receipt.
  • bash desktop/macos/tests/test-fault-suite-owned-app-cleanup.sh
    • Passed success, failure, termination, port-collision, and token-bound cleanup cases with source validation enabled.
  • All hermetic desktop/macos/tests/test-*.sh launcher checks (excluding the two documented live named-bundle checks)
    • Passed on the rebased branch.
  • DEVELOPER_DIR=/Applications/Xcode_26.6.app/Contents/Developer xcrun swift test --package-path desktop/macos/Desktop --filter 'DesktopBuildIdentityTests|DesktopAutomationBridgeRouteTests.testUnauthenticatedHealthReportsBackendAndRuntimeProtocolIdentity'
    • 5 tests passed, 0 failures on the repository-pinned Xcode 26.6 toolchain.
  • DEVELOPER_DIR=/Applications/Xcode_26.6.app/Contents/Developer OMI_APP_NAME=omi-build-identity OMI_AUTOMATION_PORT=47931 ./run.sh --yolo --no-wait
    • Built, signed, audited, installed, and launched /Applications/omi-build-identity.app through the real full-bundle path, then refreshed the final revision through the executable-only fast path.
  • OMI_AUTOMATION_PORT=47931 ./scripts/omi-ctl health
    • Running bundle reported sourceIdentity.revision=a57dda02053811419053d4983ce69c90e33fdbcd, workingTreeState=clean, and schemaVersion=1.
  • /usr/libexec/PlistBuddy against the installed Info.plist plus codesign --verify --deep --strict /Applications/omi-build-identity.app
    • Installed metadata matched the health receipt and the signed bundle verified successfully.
  • DEVELOPER_DIR=/Applications/Xcode_26.6.app/Contents/Developer ./scripts/desktop-core-harness.sh --tier 1 --bundle omi-build-identity --port 47931
    • The harness first printed the matching runtime SHA/clean state, then passed all 3 tier-1 flows.

Tests

  • DesktopBuildIdentityTests covers clean, dirty, missing, partial, and malformed metadata.
  • DesktopAutomationBridgeRouteTests covers the real unauthenticated health encoder and explicit unknown fallback in an unstamped XCTest host.
  • test-desktop-build-identity.sh exercises the production plist stamper and the same health validator called by the E2E harness, including stale-revision and unknown-identity rejection cases.
  • desktop-build-source-identity registers the guard in the deterministic local/CI check manifest.

Failure class (fixes)

Failure-Class: new

Failure-class transition narrative (only when needed)

The violated contract was that revision-specific runtime evidence must be owned by the executing artifact, while the workflow previously borrowed identity from the checkout doing the inspection. FC-runtime-evidence-without-artifact-identity makes the canonical guard a signed, versioned bundle receipt plus fail-closed runtime comparison; the production stamper, Swift parser, health route, harness validator, and deterministic tests are the supporting evidence.

New guards (only when adding a check or ratchet)

This guard would have caught the ambiguity reported in #13126 before a reused E2E bundle could support a revision-specific claim. It is implemented as a shared primitive rather than a one-off check: full builds, fast rebuilds, omi-ctl health, and the tiered harness all use the same receipt contract.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The identity contract accepts malformed metadata and cannot distinguish different dirty worktrees at the same commit.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds signed source receipts to named macOS bundles and validates them through /health and the E2E harness.

Changes:

  • Adds receipt generation, plist stamping, Swift parsing, and health validation.
  • Updates full/fast bundle flows and fault-test fixtures.
  • Documents and registers source-identity verification.
File summaries
File Description
desktop/macos/run.sh Stamps receipts before signing.
desktop/macos/scripts/desktop-build-identity.sh Generates and embeds source identity.
desktop/macos/scripts/desktop-health-check.py Validates health identity.
desktop/macos/scripts/desktop-core-harness.sh Compares runtime and checkout identity.
desktop/macos/Desktop/Sources/Automation/DesktopBuildIdentity.swift Parses receipt metadata and defines health payload.
desktop/macos/Desktop/Sources/DesktopAutomationBridge.swift Exposes identity through /health.
desktop/macos/Desktop/Tests/DesktopBuildIdentityTests.swift Tests receipt parsing.
desktop/macos/Desktop/Tests/DesktopAutomationBridgeRouteTests.swift Tests health response identity.
desktop/macos/tests/test-desktop-build-identity.sh Tests stamping and validation.
desktop/macos/tests/test-fault-suite-launch-env.sh Updates fault launch fixtures.
desktop/macos/tests/test-fault-suite-owned-app-cleanup.sh Updates cleanup fixtures.
desktop/macos/e2e/SKILL.md Documents receipt inspection.
desktop/macos/e2e/CORE_E2E.md Documents evidence binding.
desktop/macos/e2e/flows/harness-smoke.yaml Covers the new identity source.
.github/checks-manifest.yaml Registers the deterministic guard.
.github/failure-classes/FC-runtime-evidence-without-artifact-identity.json Records the failure class.
desktop/macos/changelog/unreleased/20260917-desktop-build-identity.json Adds changelog metadata.
Review details
  • Files reviewed: 17/17 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +35 to +36
let schemaVersion = infoDictionary[schemaVersionInfoKey] as? NSNumber,
schemaVersion.intValue == metadataSchemaVersion,
Comment on lines +48 to +51
identity = {
"schemaVersion": 1,
"revision": revision,
"workingTreeState": "dirty" if status.stdout else "clean",
"expected source identity is not revision-specific: "
f"{expected_source_identity}"
)
if source_identity != expected_source_identity:
@Git-on-my-level

Copy link
Copy Markdown
Member

Reviewed against #13126 — this is a well-executed fix, and the fail-closed design is the right call.

What I verified in the diff:

  • desktop/macos/scripts/desktop-build-identity.sh — identity is computed from git rev-parse --show-toplevel (so the working-tree state can't be hidden by the caller's cwd) and any git failure degrades to {revision: unknown, workingTreeState: unknown} rather than guessing. Stamping rewrites the plist atomically (mkstemp in the plist's directory + fsync + os.replace) and preserves the file mode, and run.sh calls it before codesigning on both the full-bundle and FAST_BUNDLE paths — so the receipt is inside the signed artifact, not beside it.
  • DesktopBuildIdentity.swift — parsing treats schema version, 40-char lowercase-hex revision, and a clean/dirty tree state as one receipt; any partial or malformed combination returns .unknown. Older bundles can't borrow the inspecting checkout's identity. DesktopAutomationBridge.swift moves the health struct next to this type and adds sourceIdentity to /health — one field, no other route changes.
  • desktop-health-check.py — when an expected identity is supplied, both sides must be revision-specific (40-hex + clean/dirty) and equal; unknown can never satisfy an evidence claim.
  • desktop-core-harness.sh — bridge_health and verify_fault_bundle_health now require the checkout receipt, so under set -euo pipefail every T1+/fault run fails before flows execute if a stale pool slot or another worktree's bundle is on the port. The self-check gains a source-mismatch fixture alongside the existing protocol-mismatch one.
  • Tests — test-desktop-build-identity.sh is hermetic (temp repos via git init, python httpd-style fixtures): covers clean, dirty, non-repository/unknown, matching-health, stale-health rejection, and unknown-as-evidence rejection. The fault-suite tests stub git with 40-hex revisions so the fixtures keep working under the new verification. DesktopBuildIdentityTests.swift covers the malformed/partial matrix, and the route test pins the unknown default.
  • .github/checks-manifest.yaml registers desktop-build-source-identity for the new test with sensible triggers; FC-runtime-evidence-without-artifact-identity.json matches the sibling failure-class schema (same keys, evidence_prs: [] while open). harness-smoke.yaml adds the new source file to covers. Changelog entry (kind: none) matches an engineering-only change.

One small gap, not blocking: bridge_health compares only revision + workingTreeState, so a T1 run whose bundle was built from a different branch at the same commit SHA (or vice versa) is indistinguishable — for the current single-revision evidence model that seems fine, but worth a maintainer's confirm.

The agent-guidance updates in e2e/SKILL.md and e2e/CORE_E2E.md are accurate against the code (I checked each claim above) and point verification at the artifact's own receipt — good anti-spoofing direction for automated workflows.

Because this changes the CI checks manifest and the bundle-signing pipeline and adds a field to the unauthenticated /health response, it needs maintainer sign-off on those surfaces before merge; everything I could verify statically and in the registered tests checks out.

— automated review on behalf of the Omi maintainers


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added macOS workflow-review Needs maintainer review for workflow, automation, hooks, or CI behavior needs-maintainer-review Needs a human maintainer to sign off before merge labels Sep 17, 2026

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Desktop bug-fix heuristic 3/5 (fix + closes #13126 + clear symptom narrative) -- owner-override eligible. CI clean, no abuse signals found in diff (checked scripts for eval/shell=True/secrets, none). mergeStateStatus UNKNOWN after refetch -- approve only per override b, not merged.

@Git-on-my-level

Copy link
Copy Markdown
Member

Follow-up on the same head (a57dda0) after @kodjima33's approval.

My earlier review asked for maintainer sign-off on three surfaces: the CI checks manifest, the bundle-signing pipeline, and the new field on the unauthenticated /health response. That sign-off has now landed, so I've removed needs-maintainer-review / workflow-review and added positive-signal — @aryanorastar, this is a nicely executed fix.

What I re-verified on this pass, beyond the earlier audit:

  • desktop/macos/scripts/desktop-core-harness.sh — bridge_health() and verify_fault_bundle_health() both derive the expected receipt via checkout_source_identity() and hand it to the health checker under set -euo pipefail, so a failed identity computation aborts the run instead of skipping the check; the fault path keeps the source receipt mandatory even though protocol readiness is not required there.
  • desktop/macos/scripts/desktop-health-check.py — _is_revision_specific_identity() gates the expected side too, so a non-git checkout (identity unknown) can never be the basis for a passing evidence run; comparison is strict equality after JSON parsing.
  • desktop/macos/run.sh — omi_stamp_desktop_build_identity runs before sign_app_bundle on the FAST_BUNDLE path and before signing on the full-bundle path, so the receipt lands inside the signed artifact on both.
  • desktop/macos/tests/test-fault-suite-launch-env.sh / test-fault-suite-owned-app-cleanup.sh — the old deadbeef git stub became a proper arg-dispatching stub returning a 40-hex revision, keeping the fixtures honest under the new verification rather than weakening it.

One acknowledged trade-off, not a blocker: /health now discloses the checkout commit and clean/dirty state to any local process. That localhost-only surface already exposes PID, log paths, and backend URLs, and the receipt is exactly what makes stale-pool evidence detectable, so this is the right side of the trade — noting it so the approval above is made with it in mind.

Agent-guidance note: e2e/SKILL.md and e2e/CORE_E2E.md now direct verification at the running artifact's own receipt and treat unknown as non-evidence. I checked those claims against desktop-health-check.py and the harness wiring — they're accurate, and they push automated verification toward the artifact rather than the inspecting checkout, which is the anti-spoofing direction we want.

Cleared from the automation side; merge timing stays with the maintainers.

— automated review on behalf of the Omi maintainers


by AI on behalf of David

@Git-on-my-level Git-on-my-level added positive-signal Automation verified a genuine fix/quality contribution and removed needs-maintainer-review Needs a human maintainer to sign off before merge workflow-review Needs maintainer review for workflow, automation, hooks, or CI behavior labels Sep 18, 2026

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Desktop bug-fix owner-override lane: closes #13126, scores 5/5 on bug-fix heuristic (fix(desktop)-shaped, symptom described, tests added), CLEAN, CI green, no abuse signals. Merging per owner-override.

@kodjima33
kodjima33 merged commit 6d9ecff into BasedHardware:main Sep 18, 2026
51 of 54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

macOS positive-signal Automation verified a genuine fix/quality contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

E2E bundle health does not identify the source revision being verified

4 participants