bootstrap: SwiftPM skeleton, gates, bundler, and the lane procedure

Four targets (MWBCore, MWBNet, MWBMac, mwb) with a layering test that
keeps MWBCore free of AppKit/CoreGraphics/Network; tools/gates.sh as the
definition of done; tools/bundle.sh producing a signed dist/mwb.app;
tools/lane.sh for lane worktrees; smoke binary with --version and
--check-permissions. docs/loop.md records the Dev -> QA -> lead loop with
the literal dispatch prompts, the wave schedule and escalations.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
lucioandClaude Fable 5.1 committed 2026-09-15 23:46:24 -07:00
1 parent 69c0f7ab53
commit 671b3dfa61
20 files changed
+615 -20

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
{
"version": 1,
"lineLength": 110,
"indentation": { "spaces": 4 },
"maximumBlankLines": 1,
"respectsExistingLineBreaks": true,
"lineBreakBeforeControlFlowKeywords": false,
"lineBreakBeforeEachArgument": false,
"rules": {
"AlwaysUseLowerCamelCase": true,
"NeverForceUnwrap": true,
"NeverUseForceTry": true,
"NeverUseImplicitlyUnwrappedOptionals": true,
"OrderedImports": true,
"NoBlockComments": false
}
}
+25
View File
@@ -0,0 +1,25 @@
// swift-tools-version:6.0
// mwb-mac — see README.md (D1, D2) for why these four targets exist and
// what each may import. Target names are frozen (docs/features/bootstrap).
import PackageDescription
let package = Package(
name: "mwb-mac",
platforms: [.macOS(.v14)],
products: [
.executable(name: "mwb", targets: ["mwb"])
],
targets: [
// Pure logic: protocol, crypto, matrix, settings. Foundation + CommonCrypto only.
.target(name: "MWBCore"),
// Sockets: Network.framework only.
.target(name: "MWBNet", dependencies: ["MWBCore"]),
// Platform: AppKit / CoreGraphics only.
.target(name: "MWBMac", dependencies: ["MWBCore"]),
// The app: the only place MWBNet and MWBMac meet.
.executableTarget(name: "mwb", dependencies: ["MWBCore", "MWBNet", "MWBMac"]),
.testTarget(name: "MWBCoreTests", dependencies: ["MWBCore"]),
.testTarget(name: "MWBNetTests", dependencies: ["MWBNet"]),
],
swiftLanguageModes: [.v6]
)
+17 -6
View File
@@ -6,7 +6,8 @@ LAN. The point of the port is **wire compatibility**: a Mac running
mwb-mac joins a matrix with unmodified Windows PowerToys machines, using
the same security key, ports and packets.
Start with [`CLAUDE.md`](CLAUDE.md) (rules), [`docs/protocol.md`](docs/protocol.md)
Start with [`CLAUDE.md`](CLAUDE.md) (rules), [`docs/loop.md`](docs/loop.md)
(how a lane runs), [`docs/protocol.md`](docs/protocol.md)
(the wire format, with citations into the Windows source),
[`docs/topo.md`](docs/topo.md) (dependency map used to plan parallel work)
and [`TODO.md`](TODO.md) (the milestone backlog and lane briefs).
@@ -17,8 +18,10 @@ WinForms UI. Read-only.
## Status
Planning, 2026-09-15. No code yet. Toolchain verified (Xcode 27.0);
the `bootstrap` lane is next.
2026-09-15: bootstrap merged — the SwiftPM skeleton builds, the gates
are green, `mwb --version` / `--check-permissions` run. Wave 1
(`packet-codec` ‖ `cipher-stream`) is next; procedure in
[`docs/loop.md`](docs/loop.md).
## Decisions
@@ -121,16 +124,24 @@ laptops).
## Build
Requirements: macOS 14+, Swift 6.x, a working SwiftPM.
Requirements: macOS 14+, Xcode 27 (Swift 6.4); `xcode-select -p` must point at Xcode.app.
```bash
tools/gates.sh # swift-format lint, build -warnings-as-errors, guarded swift test
tools/gates.sh # xcrun swift-format lint, build -warnings-as-errors, guarded swift test
```
```bash
tools/bundle.sh # .build/release/mwb → dist/mwb.app, signed with $MWB_SIGN_IDENTITY
MWB_SIGN_IDENTITY="mwb-mac dev" tools/bundle.sh # release build → dist/mwb.app, signed
```
```bash
tools/lane.sh new packet-codec # worktree ../mwb-lanes/packet-codec on branch lane/packet-codec
```
`swift-format` ships inside the Xcode toolchain, not on `PATH`; the
scripts call it via `xcrun`. The lint config is `.swift-format`
(110 columns, force-unwrap and force-try are lint errors).
**Toolchain note (2026-09-15):** with only Command Line Tools installed
(Swift 6.4, macOS 27.0) `swift build` failed while linking the package
manifest — the CLT's `libPackageDescription.dylib` and the compiler
+26
View File
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>com.luciochen.mwb-mac</string>
<key>CFBundleName</key>
<string>mwb-mac</string>
<key>CFBundleDisplayName</key>
<string>Mouse Without Borders</string>
<key>CFBundleExecutable</key>
<string>mwb</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>14.0</string>
<key>LSUIElement</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>mwb-mac contributors</string>
</dict>
</plist>
+8
View File
@@ -0,0 +1,8 @@
/// The build's version string, printed by `mwb --version` and sent nowhere.
///
/// Kept in `MWBCore` so every layer can report the same value. Bumped by the
/// lead at release time; not derived from git so a build is reproducible.
public enum MWBVersion {
/// Semantic version of this build.
public static let string = "0.1.0-dev"
}
+28
View File
@@ -0,0 +1,28 @@
import CoreGraphics
/// Which macOS TCC permissions the current process holds.
///
/// `listen` is Input Monitoring (needed to observe key events), `post` is
/// Accessibility (needed to inject events and to run a swallowing tap).
public struct PermissionState: Equatable, Sendable {
/// Input Monitoring granted.
public let listen: Bool
/// Accessibility granted.
public let post: Bool
/// True when both permissions are granted.
public var isComplete: Bool { listen && post }
}
/// The one wrapper around the `CGPreflight*EventAccess` C API (CLAUDE.md,
/// Swift standards: C APIs are wrapped once). Only *preflight* lives here;
/// requesting is the `event-tap` lane's job, and never happens on an agent's
/// own initiative (CLAUDE.md, Workflow).
public enum Permissions {
/// Reads the current grants without prompting the user.
public static func preflight() -> PermissionState {
PermissionState(
listen: CGPreflightListenEventAccess(),
post: CGPreflightPostEventAccess())
}
}
+9
View File
@@ -0,0 +1,9 @@
import Network
/// Placeholder so the `MWBNet` target compiles before the `control-channel`
/// lane lands. That lane deletes this file (docs/topo.md §1.1).
public enum MWBNetPlaceholder {
/// The framework this target is allowed to import, named so the layering
/// rule (README D2) is visible in the placeholder itself.
public static let framework = "Network"
}
+35
View File
@@ -0,0 +1,35 @@
// mwb — the executable. Wires MWBCore, MWBNet and MWBMac together.
// Until the menubar-app lane lands this is a smoke binary: it proves the
// three targets link, and reports the two TCC permissions the app needs.
import Foundation
import MWBCore
import MWBMac
import MWBNet
let usage = """
usage: mwb --version | --check-permissions
--version print the build version and exit 0
--check-permissions print Input Monitoring / Accessibility state; exit 0 if both granted, 3 otherwise
"""
func checkPermissions() -> Int32 {
let state = Permissions.preflight()
print("input-monitoring (listen): \(state.listen ? "granted" : "missing")")
print("accessibility (post): \(state.post ? "granted" : "missing")")
if !state.isComplete {
print("grant the missing permission(s) in System Settings > Privacy & Security")
}
return state.isComplete ? 0 : 3
}
let arguments = Array(CommandLine.arguments.dropFirst())
switch arguments {
case ["--version"]:
print("mwb \(MWBVersion.string)")
exit(0)
case ["--check-permissions"]:
exit(checkPermissions())
default:
FileHandle.standardError.write(Data((usage + "\n").utf8))
exit(2)
}
+11 -6
View File
@@ -14,20 +14,22 @@ says they are independent.
- [x] **Unblock SwiftPM.** `swift build` failed with Command Line Tools
only (README §Build). Fixed 2026-09-15 by installing Xcode 27.0;
smoke build + XCTest verified. Recorded in the bootstrap README.
- [ ] `Package.swift` with targets `MWBCore`, `MWBNet`, `MWBMac`, `mwb`,
- [x] `Package.swift` with targets `MWBCore`, `MWBNet`, `MWBMac`, `mwb`,
tests `MWBCoreTests`, `MWBNetTests`; Swift 6 language mode; macOS 14
minimum. Layering is enforced by a test in `MWBCoreTests` that
greps `Sources/MWBCore` for `import AppKit|CoreGraphics|Network`
and fails on any hit.
- [ ] `tools/gates.sh`: `swift-format lint --strict --recursive Sources Tests`,
- [x] `tools/gates.sh`: `swift-format lint --strict --recursive Sources Tests`,
`swift build -Xswiftc -warnings-as-errors`, `tools/guard.sh -- swift test`.
- [ ] `tools/bundle.sh`: release build → `dist/mwb.app` (Info.plist with
- [x] `tools/bundle.sh`: release build → `dist/mwb.app` (Info.plist with
`LSUIElement = true`, bundle id `com.luciochen.mwb-mac`),
`codesign --force --sign "$MWB_SIGN_IDENTITY"`; document how to
create a self-signed identity once (D5).
- [ ] `.swift-format` config; `.gitignore` (`.build/`, `dist/`).
- [ ] Smoke executable: `mwb --version`, `mwb --check-permissions`
(prints preflight results, exit 0).
- [x] `.swift-format` config; `.gitignore` (`.build/`, `dist/`).
- [x] Smoke executable: `mwb --version`, `mwb --check-permissions`
(prints preflight results, exit 0 when complete, 3 otherwise).
- [x] `docs/loop.md` (the Dev → QA → lead procedure with literal
prompts), `docs/features/TEMPLATE.md`, `tools/lane.sh`.
## 1. Wire core (M1 — two lanes: `packet-codec` ‖ `cipher-stream`)
@@ -231,6 +233,9 @@ says they are independent.
## 8. Later (post-v1, ordered by value)
- [ ] CI on the existing Gitea runner (`.gitea/workflows/ci.yml` running
`tools/gates.sh`) — only once invariant 5 is provably safe on a
runner that shares the user's session.
- [ ] Keychain storage for `SecurityKey` (D3).
- [ ] Easy Mouse fullscreen suppression + excluded apps (`NSWorkspace`
frontmost app, `NSWindow` fullscreen detection via Accessibility).
+7
View File
@@ -0,0 +1,7 @@
# Fixtures
Golden bytes and reference scripts. Owned by the `interop-vectors` lane
(TODO §6.2); `packet-codec` and `cipher-stream` may add hand-assembled
vectors here in their own subdirectories. Nothing in this directory is
generated by our own encoder — that would test the encoder against
itself (CLAUDE.md invariant 1).
+46
View File
@@ -0,0 +1,46 @@
import Foundation
import XCTest
/// Enforces README D2 / docs/topo.md §1: `MWBCore` is pure logic and may
/// import only Foundation and CommonCrypto (plus CryptoKit for hashing).
/// A platform or network import in the core target fails this test.
final class LayeringTests: XCTestCase {
private static let forbidden = [
"AppKit", "Cocoa", "CoreGraphics", "Carbon", "SwiftUI", "Network", "IOKit", "ApplicationServices",
]
func testCoreImportsOnlyFoundationAndCrypto() throws {
let core = coreSourcesDirectory()
let files = try swiftFiles(under: core)
XCTAssertFalse(files.isEmpty, "no Swift sources found under \(core.path)")
for file in files {
let text = try String(contentsOf: file, encoding: .utf8)
for (number, line) in text.split(separator: "\n", omittingEmptySubsequences: false).enumerated() {
let trimmed = line.trimmingCharacters(in: .whitespaces)
guard trimmed.hasPrefix("import ") else { continue }
let module =
trimmed.dropFirst("import ".count).split(separator: " ").first.map(String.init) ?? ""
XCTAssertFalse(
Self.forbidden.contains(module),
"\(file.lastPathComponent):\(number + 1) imports \(module); MWBCore is Foundation-only (README D2)"
)
}
}
}
private func coreSourcesDirectory() -> URL {
// Tests/MWBCoreTests/LayeringTests.swift → repo root → Sources/MWBCore
URL(fileURLWithPath: #filePath)
.deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent()
.appendingPathComponent("Sources/MWBCore", isDirectory: true)
}
private func swiftFiles(under directory: URL) throws -> [URL] {
let keys: [URLResourceKey] = [.isRegularFileKey]
guard let walker = FileManager.default.enumerator(at: directory, includingPropertiesForKeys: keys)
else {
return []
}
return walker.compactMap { $0 as? URL }.filter { $0.pathExtension == "swift" }
}
}
+9
View File
@@ -0,0 +1,9 @@
import MWBCore
import XCTest
final class VersionTests: XCTestCase {
func testVersionLooksSemantic() {
let parts = MWBVersion.string.split(separator: "-").first?.split(separator: ".") ?? []
XCTAssertEqual(parts.count, 3, "expected MAJOR.MINOR.PATCH[-suffix], got \(MWBVersion.string)")
}
}
+10
View File
@@ -0,0 +1,10 @@
import MWBNet
import XCTest
/// Exists so the `MWBNetTests` target is wired up before `control-channel`
/// replaces it with the loopback suite (TODO §3.1).
final class PlaceholderTests: XCTestCase {
func testTargetLinks() {
XCTAssertEqual(MWBNetPlaceholder.framework, "Network")
}
}
+39
View File
@@ -0,0 +1,39 @@
# <feature-name>
<!-- Copy to docs/features/<feature-name>/README.md. The lead writes Goal,
Assumptions, Handshakes and Status/TODO as the brief; Dev owns the
Work log; QA owns the QA log; the lead alone writes Review. -->
## Goal
One paragraph: what this lane delivers, why it exists, and which
`docs/protocol.md` sections it implements.
## Assumptions
- Every judgement call that is not enforced by code, one bullet each,
with the Windows citation (`App/<path>.cs:<line>`) where one exists.
## Handshakes
### Promised (topo.md handshake N, to <consumer lanes>)
```swift
// public API sketch; may change during the lane, README updated in the same change
```
### Consumed
- `<lane>`: `<API>` as published in its README.
## Status / TODO
- [ ] `<file>`: item
- [ ] `Tests/<target>/<file>`: item
- [ ] `docs/protocol.md`: citations verified / marks flipped
## Work log
## QA log
## Review
+30 -6
View File
@@ -54,12 +54,20 @@ works on this machine at all. Nothing in later lanes can start until
- [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`.
- [ ] `Package.swift`, empty targets with one placeholder type each,
`Tests/MWBCoreTests/LayeringTests.swift`.
- [ ] `tools/gates.sh`, `.swift-format`.
- [ ] `tools/bundle.sh` + `Resources/Info.plist`.
- [ ] `mwb --version`, `mwb --check-permissions`.
- [ ] `tools/gates.sh` green; record Swift/Xcode versions in the work log.
- [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: 3 XCTest cases, 0 warnings, lint clean.
- [ ] 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
@@ -70,7 +78,23 @@ works on this machine at all. Nothing in later lanes can start until
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.
+173
View File
@@ -0,0 +1,173 @@
# loop.md — the Dev → QA → lead loop
**Purpose.** How a lane goes from a brief to a merged commit, who does
what, and the literal prompts the lead dispatches. `CLAUDE.md` states
the rules; this file is the procedure. The lead follows it verbatim so
that every lane leaves the same trail: a feature README with Work log,
QA log and Review filled in, ticked TODO lines, and a `--no-ff` merge.
## 0. Roles
| role | model | owns | never |
|---|---|---|---|
| **Lead** | Fable 5.1 (this session) | trunk (`main`), wave planning, briefs, dispatch, the self-inspect review, merges, commits, pushes, `docs/topo.md` | writes lane code (bootstrap was the one exception); trusts a report it has not checked |
| **Dev** | Opus | one lane in one worktree: code, tests, README Work log, ticks in Status/TODO and `TODO.md` | commits; touches files outside the brief's list; asks for permissions |
| **QA** | Sonnet | the same worktree after Dev: verification, attack tests, README QA log, a verdict | redesigns; edits anything but tests, the QA log and small unambiguous fixes it records |
"Self inspect" is the lead's review: the lead reads the diff with its own
eyes and runs the gates itself before writing the Review section. A
green QA verdict is evidence, not a decision.
## 1. Lifecycle of a lane
1. **Pick the wave.** `docs/topo.md` §3 says which two lanes may run
together. Anything not in that table runs alone.
2. **Write the brief** on `main`: `docs/features/<name>/README.md` with
Goal, Assumptions, Handshakes and a Status/TODO whose items name
their files (template: `docs/features/TEMPLATE.md`). The file list
*is* the merge contract. Commit as `brief: <name>`.
3. **Open the lane**: `tools/lane.sh new <name>` → worktree at
`../mwb-lanes/<name>` on branch `lane/<name>`.
4. **Dispatch Dev** with the prompt in §3, `cwd` = the worktree. Dev
finishes only when `tools/gates.sh` is green in the worktree.
5. **Dispatch QA** with the prompt in §4, same worktree. Verdict is
`PASS` or `REWORK` with file:line findings.
6. **On REWORK**, dispatch Dev again with the QA log as input. At most
two rework rounds; a third means the brief was wrong — the lead
rewrites the brief and restarts the lane.
7. **Self-inspect** (§5). Write the Review section. If review finds a
defect, it goes back to step 4 as a rework with the review text as
the finding.
8. **Merge**: on `main`, `git merge --no-ff lane/<name>`, run
`tools/gates.sh` on the merged tree, update `docs/topo.md` for any
edge the lane added or amended, tick the wave line in `TODO.md`,
commit, push, `tools/lane.sh done <name>`, delete the branch.
9. **Log the wave** in §8 of this file: dates, rework count, what the
brief got wrong.
Two lanes in flight follow the same steps independently. Their merges
are sequential; the second lane's merge re-runs gates on a trunk that
already contains the first.
## 2. What a brief must contain
- **Goal**: one paragraph, what and why, which `docs/protocol.md`
sections it implements.
- **Assumptions**: every judgement call the dev would otherwise have to
make. If the lead cannot write this section, the lane is not ready.
- **Handshakes / Promised**: the public API sketched in Swift, marked
"may change during the lane; README updated in the same change".
- **Handshakes / Consumed**: which other lanes' APIs it uses, by README
reference, never by reading their source for undocumented behaviour.
- **Status / TODO**: 4–8 checkbox items, each naming the file(s) it
touches. The union of those files is the ownership list.
- **Citations**: every fact from the Windows source as
`App/<path>.cs:<line>`, matching `docs/protocol.md`.
## 3. Dev prompt (dispatch verbatim, fill the brackets)
```
You are the Dev for lane `<name>` of mwb-mac. Work only in this worktree:
<absolute worktree path> (branch lane/<name>). Read, in order: CLAUDE.md,
README.md, docs/protocol.md, docs/topo.md, docs/features/<name>/README.md.
The README's Status/TODO is your task list and its file list is the only
set of files you may create or edit, plus: docs/features/<name>/README.md
(Assumptions, Handshakes, Status/TODO, Work log), TODO.md (tick your own
lines only), docs/protocol.md (append citations you verified, in your
lane's own subsection), docs/perf/README.md (append measurements).
Rules that end a lane if broken: CLAUDE.md invariants 1–5; no git commit;
no file outside the list — write a Handshake request in your README and
stop that item instead; every test run through tools/guard.sh; never set
MWB_ALLOW_INPUT_TESTS.
Done means: every Status/TODO item ticked or explicitly marked "not done,
deliberately: <why>"; tools/gates.sh exits 0 in this worktree; the Work
log has a dated entry with decisions and deviations; any API change is
reflected in Handshakes. Report: what you built, what you deviated from,
open handshake requests, and the gates.sh tail.
```
## 4. QA prompt (dispatch verbatim)
```
You are QA for lane `<name>` of mwb-mac, in worktree <absolute path>
(branch lane/<name>). Dev is finished. Read CLAUDE.md, docs/protocol.md,
docs/features/<name>/README.md (all sections), then the diff:
git diff main...HEAD.
Verify, do not redesign. In order: (1) run tools/gates.sh yourself;
(2) check each Status/TODO tick against the code and tests — a tick with
no test is a finding; (3) check every protocol claim in the code against
docs/protocol.md and, where cited, the Windows source at
/Users/guoliangchen/repo/PowerToys/src/modules/MouseWithoutBorders/App/
— a mismatch is a finding with both file:line references; (4) try to
break it: malformed bytes, boundary sizes, wrong key, empty/oversized
input, concurrency where the API is Sendable; add the attack as a test in
the lane's test files; (5) check CLAUDE.md file/function size limits and
the layering test; (6) confirm nothing logs key material.
You may fix only typos and missing assertions, and must note each fix in
the QA log. Everything else is a finding: file:line, reproduction, and
what you expected. Write a dated QA log entry ending with a verdict line
`Verdict: PASS` or `Verdict: REWORK` and the findings list. Never set
MWB_ALLOW_INPUT_TESTS; every test run goes through tools/guard.sh.
Report the verdict and the findings.
```
## 5. Lead self-inspect checklist
Run in the worktree, by the lead, before writing Review:
- [ ] `tools/gates.sh` green, run by me.
- [ ] `git diff main...HEAD --stat`: only files in the brief's list (plus
the shared-by-nature files, in the lane's own sections).
- [ ] Read the whole diff. Every protocol constant traces to a
`docs/protocol.md` line; every offset matches §1.1.
- [ ] Invariant 1: golden bytes come from a fixture or a hand assembly
in the test, never from the encoder under test.
- [ ] Invariant 2: no code path acts on a packet before framing + decrypt
succeed; no `print`/`Logger` call includes key, salt, IV or keystrokes.
- [ ] Invariants 3–5 where the lane touches `MWBMac`.
- [ ] File sizes under 600 production lines; functions under 50 unless
commented; no `!`, `try!`, `fatalError` in `Sources/`.
- [ ] Handshakes section matches the code's public API; any change is
also in the Work log.
- [ ] The QA log's findings are each resolved in the Work log or
explicitly deferred with a TODO line.
- [ ] `TODO.md` ticks are only this lane's lines.
Write `## Review` with the date, verdict (merge / rework), and what to
carry into the next brief. The Review section is the only place the lead
writes in a lane's README.
## 6. Wave schedule
| wave | lanes | gate to start | status |
|---|---|---|---|
| 0 | bootstrap | — | merged 2026-09-15 (lead, solo) |
| 1 | packet-codec ‖ cipher-stream | wave 0 merged | briefs written; not dispatched |
| 2 | session ‖ matrix-edge | wave 1 merged | briefs to write |
| 3 | control-channel ‖ event-tap | wave 2 merged | briefs to write |
| 4 | input-inject ‖ screens-cursor | wave 3 merged; screens-cursor README published first (topo handshake 6) | |
| 5 | clipboard-inband ‖ menubar-app | wave 4 merged | |
| 6 | clipboard-bulk ‖ interop-vectors | wave 5 merged; interop-vectors needs a Windows machine (§7) | |
| 7 | end-to-end, then soak | wave 6 merged; needs real devices and `MWB_ALLOW_INPUT_TESTS=1` with the user present | |
## 7. Escalations — things only the user can do
- **Grant permissions** (Accessibility, Input Monitoring) to
`dist/mwb.app` in System Settings, and create the self-signed
`MWB_SIGN_IDENTITY` once (`tools/bundle.sh` header).
- **Provide a Windows machine** with PowerToys for `interop-vectors`
(or a packet capture of a Windows↔Windows session plus its key).
- **Be present** for any run with `MWB_ALLOW_INPUT_TESTS=1`; the lead
says so in the report before dispatching such a step.
- **Approve pushes** of anything beyond the merge of a reviewed lane.
## 8. Wave log
- **2026-09-15, wave 0 (bootstrap)** — done by the lead alone at the
user's request. No Dev/QA round. What the brief got wrong: nothing
yet; the toolchain assumption (Xcode required) held. `swift-format`
is not on `PATH` — the gate calls it through `xcrun`.
+20 -2
View File
@@ -10,8 +10,9 @@ open handshakes before assigning ownership.
Sources of truth this document is derived from (and defers to on
conflict): `Package.swift`, each `docs/features/<name>/README.md`
(**Handshakes** in particular), `README.md`, `CLAUDE.md`,
`docs/protocol.md`. Drafted 2026-09-15 at planning time, before any code;
the lead updates it after every merged lane.
`docs/protocol.md`. Drafted 2026-09-15 at planning time; updated the same day after the
bootstrap merge (skeleton exists, file ownership tables below reflect it).
The lead updates it after every merged lane.
**Edge notation:**
@@ -63,6 +64,23 @@ Standing promises:
| `ClipboardCodec.swift` | clipboard-inband | clipboard-bulk (header format only) |
| `Settings.swift` | menubar-app | everyone via `mwb` |
`MWBMac` files owned at planning time:
| file | lane | note |
|---|---|---|
| `Permissions.swift` | bootstrap → **event-tap** | preflight shipped by bootstrap; event-tap adds `request…` and owns the file from wave 3 |
| `EventTap.swift` | event-tap | |
| `Injector.swift` | input-inject | defines the injected-event tag (handshake 5) |
| `Screens.swift`, `Cursor.swift` | screens-cursor | |
| `Pasteboard.swift` | clipboard-inband | |
| `StatusItem.swift` | menubar-app | |
`MWBNet/Placeholder.swift` is deleted by control-channel;
`Tests/MWBNetTests/PlaceholderTests.swift` likewise.
Tooling (`tools/`, `Package.swift`, `.swift-format`, `Resources/`) is the
lead's; a lane needing a change there files a Handshake request.
## 2. Feature dependency graph
### 2.1 Milestone order (sequencing, `─▶`)
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
# Release build → dist/mwb.app, signed.
#
# Usage: MWB_SIGN_IDENTITY="mwb-mac dev" tools/bundle.sh
# MWB_ADHOC=1 tools/bundle.sh # ad-hoc signature, for a throwaway build only
#
# A stable signing identity matters: macOS TCC ties the Accessibility and
# Input Monitoring grants to the code signature, and an ad-hoc signature
# changes with every build, so the user would be re-prompted each time
# (README D5). Create a self-signed identity once with Keychain Access
# (Certificate Assistant > Create a Certificate, type "Code Signing") and
# pass its name via MWB_SIGN_IDENTITY.
set -euo pipefail
root=$(cd "$(dirname "$0")/.." && pwd)
cd "$root"
app="dist/mwb.app"
identity="${MWB_SIGN_IDENTITY:-}"
if [ -z "$identity" ]; then
if [ "${MWB_ADHOC:-0}" = 1 ]; then
identity="-"
echo "bundle.sh: ad-hoc signing (MWB_ADHOC=1); TCC grants will not persist across builds" >&2
else
echo "bundle.sh: set MWB_SIGN_IDENTITY to a code-signing identity, or MWB_ADHOC=1 for a throwaway build" >&2
exit 2
fi
fi
swift build -c release 2>&1 | grep -v '^\[' || true
swift build -c release >/dev/null
bin=$(swift build -c release --show-bin-path)/mwb
rm -rf "$app"
mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources"
cp "$bin" "$app/Contents/MacOS/mwb"
cp Resources/Info.plist "$app/Contents/Info.plist"
codesign --force --sign "$identity" --options runtime --timestamp=none "$app"
codesign --verify --verbose=2 "$app"
echo "built $app"
Executable
+32
View File
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
# The definition of "done" for every lane (CLAUDE.md, Swift standards):
# 1. swift-format lint --strict is clean
# 2. swift build with warnings as errors is clean
# 3. swift test is green, under the runaway guard
# Exit 0 only if all three pass. Run from anywhere; operates on the repo
# that contains this script (so it works inside a lane worktree).
#
# Usage: tools/gates.sh [--no-test]
set -euo pipefail
root=$(cd "$(dirname "$0")/.." && pwd)
cd "$root"
run_tests=1
[ "${1:-}" = "--no-test" ] && run_tests=0
echo "== gate 1/3: swift-format lint --strict"
xcrun swift-format lint --strict --recursive Sources Tests Package.swift
echo "== gate 2/3: swift build -Xswiftc -warnings-as-errors"
swift build -Xswiftc -warnings-as-errors 2>&1 | grep -v '^\[' || true
# grep swallows the exit status; re-check with a cheap incremental build.
swift build -Xswiftc -warnings-as-errors >/dev/null
if [ "$run_tests" = 1 ]; then
echo "== gate 3/3: swift test (guarded: 8 GB / 15 min)"
# pipefail is set, so a guard kill or a failing test fails this line.
tools/guard.sh -m 8 -t 900 -- swift test 2>&1 | grep -E "Executed|error:|failed|passed after" | tail -20
else
echo "== gate 3/3: skipped (--no-test)"
fi
echo "== gates: all green"
Executable
+34
View File
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
# Lane worktrees for the Dev → QA → lead loop (docs/loop.md).
#
# tools/lane.sh new <feature> create ../mwb-lanes/<feature> on branch lane/<feature> from main
# tools/lane.sh list show live lanes
# tools/lane.sh done <feature> remove the worktree (branch is kept until the lead deletes it)
#
# One worktree per lane, never two agents in one tree (CLAUDE.md,
# Parallel lanes). The lead merges lane/<feature> into main with --no-ff
# after QA verdict and review, then runs `done`.
set -euo pipefail
root=$(cd "$(dirname "$0")/.." && pwd)
lanes="$(dirname "$root")/mwb-lanes"
cmd="${1:-}"; name="${2:-}"
case "$cmd" in
new)
[ -n "$name" ] || { echo "usage: $0 new <feature>" >&2; exit 2; }
[ -d "$root/docs/features/$name" ] || { echo "no docs/features/$name — write the brief first (docs/loop.md §2)" >&2; exit 2; }
mkdir -p "$lanes"
git -C "$root" worktree add -b "lane/$name" "$lanes/$name" main
echo "lane ready: $lanes/$name (branch lane/$name)"
;;
list)
git -C "$root" worktree list
;;
done)
[ -n "$name" ] || { echo "usage: $0 done <feature>" >&2; exit 2; }
git -C "$root" worktree remove "$lanes/$name"
echo "removed $lanes/$name; branch lane/$name kept"
;;
*)
echo "usage: $0 new <feature> | list | done <feature>" >&2; exit 2 ;;
esac