Skip to content

Colocate platform-specific code with its platform package (0.22 plugin extraction) #4740

Open

Description

@thymikee

Summary

0.22 extracts providers and some platforms into plugins (#3309, #3310, #3311). The core must stay lean.
Native sources, and platform logic that only one platform uses, must live with the owning platform package.
The first PR moves the recording Swift helpers out of capture-kit into a new host-tool package, packages/host-swift.
This issue tracks the remaining items. Each needs a port design or a policy decision, not a mechanical move.

Findings

  • The recording Swift helpers (touch overlay, frame decoder, video validator) are macOS host tools, not Apple-platform code. Android, HarmonyOS, Apple and provider recordings all use them on a macOS host. They do not belong in platform-apple, and they do not block its extraction.
  • No other Swift, Objective-C, Java or Kotlin source sits in a non-platform package. Native trees stay under apple/ and android/.

Remaining items

Can move; the dependency direction allows it

  • contracts/src/apple-runner-request.ts (18 lines, type only). Only consumer: apple-runner. Proposed owner: apple-runner.
  • capture-kit/src/snapshot/ios-snapshot-runtime.ts (188 lines). Only consumer: daemon. Proposed owner: platform-apple. R72 (ios-snapshot-engine-policy.ts) and provider-snapshot-presentation-policy.ts pin the path.
  • contracts/src/ios-target-activation.ts (42 lines). Consumers: daemon, platform-apple. Proposed owner: platform-apple.
  • contracts/src/android-clipboard-support.ts (13 lines). Consumer: platform-android, plus one contracts-internal import. Proposed owner: platform-android.

Blocked: a shared package consumes the item (needs a port or a hook)

  • capture-kit/src/ios-snapshot-engine/ (about 4,200 lines) and the ./ios-snapshot-tree export. Blocked by maestro and selectors. Proposed owner: platform-apple, behind a presentation port. conformance-harness.ts (runs swift build on apple/snapshot-presentation) moves with the engine.
  • capture-kit ios-node-interpretation, ios-snapshot-acquisition, ios-ax-tree. Blocked by provider-webdriver and provider-revyl. Proposed owner: platform-apple, as a port that providers receive.
  • capture-kit/src/ios-snapshot-planning.ts. Blocked by capture-kit snapshot-state and snapshot-router.
  • capture-kit/src/snapshot/snapshot-presentation/android/* (505 lines). Blocked by command-output. Proposed owner: platform-android.
  • capture-kit android-replacement-surface-occlusion, snapshot-freshness/android, network-traffic-android, screenshot-overlay-android. Each needs an injected hook in its shared caller. Proposed owner: platform-android.
  • contracts android-input-ownership, android-snapshot-quality, android-system-chrome, android-system-surface-disclosure, ios-snapshot, ios-system-surface. Consumed by capture-kit, command-runtime, replay-port, provider-webdriver. Decide per item: shared data stays in contracts; platform behavior moves behind a registry hook.
  • kernel/src/device-shell.ts. Serves Android and HarmonyOS. Stays shared unless a second split is worth it.

Correct by current policy; moving them is a policy change

  • Root src/platform-runtime-*android* and *apple* host bindings (adb, emulator, simctl, xcrun, devicectl). root-module-zones.ts, R13 and platform-composition-policy.ts keep host binding in the root. Moving them needs an ADR 0019 amendment.
  • Root src/core/interactors/limrun-ios-* (8 files, about 1,290 lines). Proposed owner: provider-limrun, with an Apple runner port from platform-apple. Ties into refactor(provider-limrun): ship Limrun as the @agent-device/limrun plugin #3311.
  • daemon single-platform modules: execution/android-system-dialog.ts, execution/android-snapshot-timeout-evidence.ts, execution/android-foreground-surface.ts, core/stopped-local-android-device.ts, interaction-ios-tap-outcome.ts, interaction-touch-direct-ios.ts, core/direct-ios-selector.ts, core/ios-app-session-hint.ts, resources/macos-app-lease.ts, session-appstate-apple-session.ts. Each imports daemon internals and needs a daemon port first.

Follow-ups to the host-swift move

  • Move the video validator from an inline TS string (host-swift/src/video-validator-source.ts) to a .swift file under the generator. Decision needed: a file adds a trailing newline, so the validator's compile cache key changes once (one recompile after upgrade).
  • Optional: move the recording drivers (overlay.ts, contact-sheet-frames.ts, the playability half of video.ts) into a host-media package above capture-kit. Needs a video.ts split and an injected frame-extractor port in buildRecordingContactSheet. Not required for 0.22.

Completion

Each item above is moved, or closed with a Decision: comment. No non-platform package holds native source or single-platform logic without a recorded reason.

Blocked by: nothing. Related: #3309, #3310, #3311, ADR 0019, ADR 0034.

Activity

  1. apex-sentinel-staging commented on Nov 19, 2026

    @apex-sentinel-staging

    Apex Sentinel · Issue review

    Suggested label: feature

    The issue describes desired code organization work for the 0.22 plugin extraction, listing remaining platform-specific items to move or close with policy decisions rather than reporting broken behavior. It is actionable because it provides concrete files, proposed owners, blockers, and completion criteria, while some items still need design decisions.

  2. thymikee commented on Nov 19, 2026

    @thymikee
    MemberAuthor

    Current state: #4742 merged (recording Swift helpers -> packages/host-swift). #4751 open: apple-runner-request contract -> apple-runner. Next: the remaining 'Can move' items, then port designs for the blocked items.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions