Skip to content

chore: remove verified dead code and migration scaffolding (~700 LOC)#1367

Merged
thymikee merged 3 commits into
mainfrom
claude/agent-device-simplification-ac86b4
Jul 23, 2026
Merged

chore: remove verified dead code and migration scaffolding (~700 LOC)#1367
thymikee merged 3 commits into
mainfrom
claude/agent-device-simplification-ac86b4

Conversation

@thymikee

@thymikee thymikee commented Jul 22, 2026

Copy link
Copy Markdown
Member

What

Removes ~670 net lines of adversarially-verified dead code accumulated over the last months of fast iteration. Sourced from a multi-agent audit (12 finders over every subsystem + cross-cutting lenses; each candidate finding then attacked by an independent skeptic checking call sites, git history, and the published API surface — 7 of 29 candidates were refuted and are not in this PR).

Removed

Superseded migration scaffolding

  • src/core/platform-descriptor/ deleted entirely. Its capability table was an identity mapping kept alive only as a "frozen oracle" for parity tests of the completed ADR-0009 migration. The two dependent parity tests now assert an inline platform→bucket table; the one silent production dependency (plugin.ts importing the CapabilityBucket type) is inlined as a 4-literal union.
  • Runtime-layer rotate command duplicate in commands/system/runtime — unreachable since chore: remove deprecated rotate command alias (and audit remaining command-name shims) at next minor #1277 removed the CLI alias. The published SDK back-compat wrapper in agent-device-client.ts is untouched (it delegates to orientation independently and stays until next major).

Test-only seams & dead flexibility (each verified to have zero production callers)

  • CommandFacet.extraDaemonWriters + merge loop; registry introspection exports (listDescriptorDispatchCommandNames/listCapabilityCheckedCommandNames, inlined into their tests); MaestroEngineOptions.timing override; backend capability allow-list (BACKEND_CAPABILITY_NAMES/allowNamedBackendCapabilities, always []); screenshot-diff maxRegions; clearFirst on both the TS and Swift sides of the runner wire contract.

CloudWebDriverSupportLevel 'partial'dropped after review: the partial level and its notes are lease-response capability metadata for genuinely limited operations (Appium page-source snapshots, upload-then-install), not dead code. Reverted to main's state unchanged.

Deprecated surface (breaking, see below)

  • --session-locked / --session-lock-conflicts aliases across 4 layers; resolveLockMode collapses to a single override path. Both flags now fail with Unknown flag: --session-locked. Use --session-lock reject|strip instead. via the existing formatUnknownFlagMessage mechanism.
  • replay export --format — a single-value enum (maestro) with an unreachable "unsupported format" branch; export always emits Maestro YAML.
  • Lease*Payload types from ./contracts — zero consumers, duplicated DaemonRequestMeta; their runtime validators were already removed in refactor: remove production-unused exports #1203.

Pass-throughs & duplication collapsed

  • withRetry/RetryOptions (field-renaming adapter over retryWithPolicy, one caller, silently dropped policy defaults); default-cloud-artifact-provider.ts (single-caller interface wrapper, now inline at the daemon-runtime call site); connect-profile client-id hashing (3 identical sha256 helpers → one buildConnectClientId, per-profile field lists preserved so hash outputs are byte-identical); shared scripts/lib/walk-files.ts for the two strip-types guard scripts; cloneValuestructuredClone; fill-diagnostics moved from shared src/platforms/ into android/ (its only consumer — the "cross-platform" framing was fiction).

Breaking changes

Pre-1.0, all previously deprecated or dead:

  1. --session-locked / --session-lock-conflicts → hard migration error pointing at --session-lock
  2. replay export --format removed (maestro was the only legal value; behavior unchanged)
  3. LeaseAllocatePayload/LeaseHeartbeatPayload/LeaseReleasePayload types dropped from the ./contracts subpath

CHANGELOG entries added for all three.

Verification

lint · typecheck · check:layering (877 files OK) · check:production-exports · check:fallow (76 changed files, no issues) · check:mcp-metadata · build · check:bundle-owner-files · unit suite (unit-core + android-adb; two runs hit the known contention-timeout flake in daemon spawn tests — changing failure set, timeout-only, all pass in isolation) · smoke 14/14 · test:integration:progress:check (flag partition: 0 unclassified, 65/65 covered) · format:check.

The Swift edit (clearFirst removal in RunnerTests+Models.swift/RunnerTests+TextEntry.swift) is verified: pnpm build:xcuitest:iosTEST BUILD SUCCEEDED (Xcode 26.2).

Post-review updates: rebased onto main@317469f35; #1363/#1364's tightened fallow gates required two follow-up fixes (dropped a consumer-less AndroidFillVerificationNode re-export; resolveSnapshotForRef now reuses requireSnapshotSession instead of inlining the same authorized-frame block). CHANGELOG gained the Lease*Payload breaking entry.

Deliberately not in this PR

  • runCli() decomposition (cli.ts:86-476) — real altitude problem, but a refactor deserving its own review
  • Generic BoundOf<T> for the 6 pass-through bindXCommands families (selector/interaction must stay hand-written — 11/17 entries reshape signatures)
  • Legacy batch-step {command,positionals,flags} shape (~90 lines) — scheduled for next major, warning already in place
  • request-handler-chain table-ification — audit verdict was inconclusive, needs a real look

@thymikee

Copy link
Copy Markdown
Member Author

Swift verification done: pnpm build:xcuitest:ios compiles the AgentDeviceRunnerUITests target (including RunnerTests+Models.swift / RunnerTests+TextEntry.swift with the clearFirst removal) — TEST BUILD SUCCEEDED on Xcode 26.2. The ⚠️ in the description is resolved.

thymikee added 2 commits July 22, 2026 20:35
Multi-agent audit of accumulated waste, every finding adversarially
verified against call sites, git history, and the published surface
before removal. Net -710 lines.

- delete src/core/platform-descriptor/ (superseded ADR-0009 migration
  scaffold; parity tests now assert an inline table)
- remove test-only seams: registry introspection exports,
  CommandFacet.extraDaemonWriters, MaestroEngineOptions.timing
- remove dead flexibility: backend capability allow-list,
  screenshot-diff maxRegions, CloudWebDriverSupportLevel 'partial',
  clearFirst on the TS+Swift runner wire contract
- remove dead deprecated surface: --session-locked /
  --session-lock-conflicts aliases (hard migration error now points at
  --session-lock), replay export --format single-value enum,
  unused Lease*Payload contract types, runtime-layer rotate duplicate
- collapse pass-throughs/duplication: withRetry adapter,
  default-cloud-artifact-provider, connect-profile client-id hashing
  (3x sha256 impls -> one helper, byte-identical output), shared
  scripts walker, cloneValue -> structuredClone, fill-diagnostics
  moved into android/

BREAKING CHANGE: --session-locked and --session-lock-conflicts now fail
with a migration error pointing at --session-lock; replay export
--format is removed (Maestro was the only value); Lease*Payload types
are dropped from the ./contracts subpath.
- drop the consumer-less AndroidFillVerificationNode re-export
- reuse requireSnapshotSession in resolveSnapshotForRef instead of
  inlining the same authorized-frame resolution (fallow clone group);
  the helper's return type now guarantees the session it already
  throws for
@thymikee
thymikee force-pushed the claude/agent-device-simplification-ac86b4 branch from ff1f6b0 to 7d77f8c Compare July 22, 2026 18:38
@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown

Size Report

Metric Base Current Diff
JS raw 1.8 MB 1.8 MB -2.1 kB
JS gzip 578.2 kB 577.7 kB -502 B
npm tarball 692.9 kB 692.3 kB -660 B
npm unpacked 2.4 MB 2.4 MB -3.2 kB

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 26.9 ms 25.9 ms -1.0 ms
CLI --help 56.4 ms 63.2 ms +6.8 ms

Top changed chunks:

Chunk Raw diff Gzip diff
dist/src/registry.js -707 B -171 B
dist/src/cli.js -401 B -70 B
dist/src/runtime.js -207 B -68 B
dist/src/tv-remote.js -202 B -26 B
dist/src/internal/daemon.js -51 B -19 B

@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-07-23 05:37 UTC

@thymikee

Copy link
Copy Markdown
Member Author

Needs changes at 7d77f8c:

  1. Blocking: Cloud WebDriver capability metadata is part of the lease response, not dead scaffolding. This PR relabels limited operations from partial to supported and deletes the explanations without changing implementations or supplying provider evidence. Inventory still exposes only the leased device, snapshots still use Appium page source rather than native backends, and several mobile/clipboard operations remain provider-dependent. Preserve partial and its notes, or treat this as a separately evidenced and documented public capability-contract change. Updating the assertion to expect supported does not prove parity.

  2. The changelog covers the two CLI removals but omits removal of the published LeaseAllocatePayload, LeaseHeartbeatPayload, and LeaseReleasePayload exports from agent-device/contracts (present in v0.18.1). Add an Unreleased breaking-change entry.

All current checks, including Swift/platform smokes, are green, but the capability promotion has no live cloud-provider evidence. No separately authorized cross-vendor review was performed.

The partial/supported/unsupported levels and their notes are part of the
lease-response capability contract for genuinely limited operations
(Appium page-source snapshots, upload-then-install), not dead
scaffolding. Restore them and the asserting tests unchanged from main.

Also add the missing CHANGELOG entry for the Lease*Payload type removal
from agent-device/contracts.
@thymikee

Copy link
Copy Markdown
Member Author

Both points addressed at b24e81263:

  1. partial capability metadata restoredcapabilities.ts, browserstack.ts, and both asserting tests are reverted to main's state byte-for-byte (git checkout origin/main -- <files>). You're right that this is lease-response contract metadata, not dead scaffolding — the runtime scenario test itself reads provider.capabilities.operations.snapshot.support out of the allocate response, which should have been the tell. The audit finding is recorded as maintainer-refuted so it doesn't get re-flagged.
  2. CHANGELOG — added the Unreleased breaking entry for the LeaseAllocatePayload/LeaseHeartbeatPayload/LeaseReleasePayload removal from agent-device/contracts.

Verified after the revert: typecheck, lint, check:fallow (no issues), and both cloud-webdriver provider-scenario test files pass. PR description updated to strike the capability item and adjust the net-line figure.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Jul 22, 2026
@thymikee

Copy link
Copy Markdown
Member Author

Re-review clean at b24e812. The Cloud WebDriver partial capability levels and limitation notes are restored byte-for-byte, including BrowserStack install and lease-response assertions. The Unreleased changelog now names removal of all three published Lease*Payload exports and points to DaemonRequestMeta. All completed checks pass; only the iOS smoke remains in progress. Code review is clean and ready for human review. No separately authorized cross-vendor review was performed.

@thymikee
thymikee merged commit d237bc5 into main Jul 23, 2026
25 checks passed
@thymikee
thymikee deleted the claude/agent-device-simplification-ac86b4 branch July 23, 2026 05:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant