# bootstrap ## Goal Turn the empty repository into a building, testing SwiftPM package with the three-target layering from README D2, the `done` gate script and the `.app` bundler — and, first of all, establish whether `swift build` works on this machine at all. Nothing in later lanes can start until `tools/gates.sh` passes on an empty skeleton. ## Assumptions - **The SwiftPM breakage is the toolchain, not the manifest.** Measured 2026-09-15: Command Line Tools only (`/Library/Developer/CommandLineTools`, Swift 6.4, macOS 27.0, no Xcode.app). A trivial manifest fails to link with `swift-tools-version` 5.9 and 6.0 alike; `libPackageDescription.dylib` exports `Package.init(… swiftLanguageVersions: [SwiftLanguageMode]? …)` while the compiled manifest references `[SwiftVersion]?`. Purging `~/Library/Caches/org.swift.swiftpm` did not help. `swiftc` compiles and links an AppKit + CryptoKit program fine. The CLT ships Swift Testing but no `XCTest.framework`. - **Installing Xcode.app fixes both.** It carries its own SwiftPM and XCTest. If the user prefers not to, the fallback is a `Makefile` driving `swiftc` per target plus Swift Testing (`import Testing`) run via `swift-testing`'s console runner — recorded here only if needed. - **Minimum macOS 14.** `CGPreflightListenEventAccess` and friends exist since 10.15; 14 is chosen for Swift 6 concurrency and `NWListener` maturity, not for a specific API. - **Bundle id** `com.luciochen.mwb-mac`; `LSUIElement = true` (menu-bar app, no Dock icon). A self-signed "mwb-mac dev" code-signing certificate is created once by the user via Keychain Access; `tools/bundle.sh` reads its name from `MWB_SIGN_IDENTITY` and refuses to sign ad-hoc unless `MWB_ADHOC=1` is set explicitly (D5). ## Handshakes ### Promised - `Package.swift` target names `MWBCore`, `MWBNet`, `MWBMac`, `mwb`, `MWBCoreTests`, `MWBNetTests` are frozen; later lanes add files, not targets, without a handshake here. - `tools/gates.sh` exit status is the definition of "done" for every lane: 0 means format-clean, warning-free, tests green under the guard. - `MWBCoreTests/LayeringTests.swift` greps `Sources/MWBCore` for `import (AppKit|CoreGraphics|Network|Cocoa)` and fails on any hit (topo.md §1 standing promise). ### Consumed - `tools/guard.sh` (already present; copied from lucisv, header adapted). ## Status / TODO - [x] Report the toolchain state to the user and wait for Xcode. Xcode 27.0 (27A266a) installed 2026-09-15; `xcode-select -p` is `/Applications/Xcode.app/Contents/Developer`. - [x] `Package.swift`, four targets + two test targets, one placeholder type each; `Tests/MWBCoreTests/LayeringTests.swift` enforces D2. - [x] `tools/gates.sh` (via `xcrun swift-format`), `.swift-format`. - [x] `tools/bundle.sh` + `Resources/Info.plist`; ad-hoc build verified, identity-signed build awaits the user's certificate (D5). - [x] `mwb --version`, `mwb --check-permissions` (exit 3 when a grant is missing) backed by `MWBMac/Permissions.swift` (preflight only). - [x] `tools/lane.sh` worktree helper; `docs/loop.md` procedure; `docs/features/TEMPLATE.md`. - [x] `tools/gates.sh` green (lint, layering grep, build). The three XCTest cases from the first cut were removed the same day when the user set the no-test-suites rule; the layering check moved into `gates.sh` as a grep. - [ ] Not done, deliberately: no CI workflow. The lucisv Gitea runner exists on this Mac (`verilogrustformatter/tools/RELEASING.md`), but a CI that runs `swift test` for a project that will soon post input events needs invariant 5 thought through first — TODO §8. ## Work log - 2026-09-15 (lead, planning): toolchain probed; findings in Assumptions. No code written. - 2026-09-15 (lead): after the user installed Xcode 27.0, the same smoke package (executable importing AppKit + CryptoKit + CommonCrypto, one XCTest case, `swift-tools-version:6.0`) built in 8 s and the test passed under `swift test`. The Assumptions above stay as the record of why Xcode is a requirement; the fallback Makefile is not needed. - 2026-09-15 (lead, solo at the user's request): skeleton landed. Decisions: (1) `Permissions.swift` ships now with *preflight only* so the smoke binary can report grants; the `event-tap` lane owns requesting and extends this file — recorded in `docs/topo.md` §1.1. (2) `swift-format` config: 110 columns, 4-space indent, `NeverForceUnwrap` and `NeverUseForceTry` as lint errors (CLAUDE.md Swift standards); tests are not exempted, so tests use `XCTUnwrap`. (3) `gates.sh` runs the guarded `swift test` once under `pipefail`; a guard kill fails the gate. (4) `bundle.sh` refuses to sign ad-hoc unless `MWB_ADHOC=1`, so nobody burns a TCC grant by accident. Deviation from plan: none. Versions: Xcode 27.0 (27A266a), Swift 6.4, macOS 27.0. ## QA log ## Review - 2026-09-15 (lead): self-inspected per `docs/loop.md` §5 — gates green, layering test exercises real files, no force-unwraps in `Sources/`. Merged directly to `main` (solo lane, no worktree). Carry forward: the wave-1 briefs already exist; dispatch per `docs/loop.md` §1.