build(package): stop shipping Swift test sources

Merged
TH
1d ago
+519-31

Summary

The npm package shipped apple/macos-helper/Tests/**, but that Swift never compiles into the helper.

  • The tests move back into the shipped manifest's tree: apple/macos-helper/Package.swift declares the test targets and package.json files excludes apple/macos-helper/Tests/** from the pack.
  • The pack keeps exactly one PackStub.swift per test target: SwiftPM refuses to load a package whose declared test target has no sources, and the install-time swift build runs on the packed tree, so the stubs are load-bearing. An earlier iteration shipped a manifest without test targets behind a Sources symlink in a dev-only test package; the symlink broke Stryker's sandbox copy (EISDIR, run 39045124618) and any tool that copies the tree, and SwiftPM rejects sources outside a package root, so no split layout avoids it.
  • The publish guard (scripts/size-report-package.mjs) derives the declared test targets from the shipped manifest and requires each target's PackStub.swift in the pack; the repo guard asserts the same invariant against the real npm pack --dry-run file list, so no test source can leak back in and no stub can go missing.
  • Rejected alternatives: a FileManager.fileExists check in the shipped manifest (depends on the manifest's working directory and sandbox); a dev-only test package compiling the shipped sources (needs a directory symlink or an out-of-root path:, both rejected by tooling/SwiftPM).

Validation

  • Packed tree: npm pack, extracted into a clean dir, then swift build -c release --package-path apple/macos-helper → Build complete. The pack holds no test sources beyond Tests/AgentDeviceMacOSHelperTests/PackStub.swift and Tests/AgentDeviceMacOSInputTests/PackStub.swift.
  • Size delta vs main (npm pack --dry-run --json --ignore-scripts, identical builds): 525 → 523 files, tarball 1,435,877 → 1,433,786 B (−2,091 B), unpacked 4,661,050 → 4,653,755 B (−7,295 B).
  • pnpm test:macos-helper → 8 XCTest cases (6 Input + 2+1+5 Helper), 0 failures. Repo guard, publish-guard, and size-report tests pass.
  • Mutation: pnpm gate mutation --modules snapshot-occlusion locally → Stryker sandbox copy passes (no EISDIR), initial test run succeeded, lane envelope pass at stage complete. No repo tool copies a directory symlink anymore; the regularFile guard in scripts/lib/repo-git.ts stays as the general fix for non-blob diff sides.
  • pnpm check:affected --run --head 563d35e6ea → [passed] exactCommit=true, all runnable checks green; receipt .tmp/validation/run-zVw3OY/receipt.json.