Skip to content

refactor(apple-runner): generate the Swift runner error-code enums from runner-contract.ts - #4810

Merged
thymikee merged 3 commits into
mainfrom
t3/generate-swift-runner-error-codes
Nov 20, 2026
Merged

thymikee merged 3 commits into
mainfrom
t3/generate-swift-runner-error-codes

Conversation

@thymikee

@thymikee thymikee commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Summary

The Swift RunnerWireErrorCode and RunnerPassThroughErrorCode enums were a hand-written copy of the TypeScript declarations, kept equal by regex guards. pnpm generate:runner-error-codes now writes both enums into RunnerErrorCodes.swift from RUNNER_ERROR_CODES and RUNNER_PASS_THROUGH_CODES (moved from the guard into runner-contract.ts). All 44 constant names and raw values are identical, so there is no wire change and no protocol version bump. The change is not behaviour-changing.

  • The UITests folder is a synchronized group with one target for every platform, so the new file needs no project.pbxproj entry.
  • New runner-error-codes gate: renders again and fails on drift. Owned by the generated file, runner-contract.ts, and the generator.
  • Deleted: the 1:1 parity tests, the enum-body readers, and a second Swift enum reader with three tests in apple-runner.
  • Kept: the UPPER_SNAKE literal guard and the emitted-constant check. ErrorPayload.code is a String, so neither the generator nor the compiler sees ErrorPayload(code: "NEW_CODE") or a constant that no emit site uses. WAIVED_LITERALS is unchanged.

20 files. Generator +74; Swift +60/−99; guards and tests +169/−538. No scope expansion.

Validation

At a2138a54ef:

  • pnpm build:xcuitest:ios: TEST BUILD SUCCEEDED with RunnerErrorCodes.swift compiled (run before the rebase onto current main).
  • pnpm check:runner-error-codes, check:gate-manifest, check:affected:test, check:layering, check:fallow, check:production-exports, check:xctest-selection, check:packaged-runner-swift, check:quick: pass.
  • runner-code-literals and runner-error-classification tests: pass.

No full check:affected --run receipt: CI owns it. CI obligations: unit suite, and the iOS, macOS host, tvOS, visionOS and watchOS runner builds as evidence that every platform compiles.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff Turn on auto-fix

thymikee and others added 2 commits November 20, 2026 14:19
RunnerWireErrorCode and RunnerPassThroughErrorCode were a hand-written copy of
RUNNER_ERROR_CODES and of a pass-through list kept in a repo guard. A generator
now writes both enums into RunnerErrorCodes.swift from runner-contract.ts.
Constant names and raw values are unchanged, so the wire is unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…t gate

The runner-error-codes gate renders the Swift enums again and fails when the
checked-in file differs, so the regex readers that compared the two languages
are deleted. The literal guard stays: the generator cannot see a Swift emit
site that writes a new code as a string literal.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.45 MB 6.45 MB +208 B
Package (unpacked) 6.45 MB 6.45 MB +208 B
Package (download) 1.97 MB 1.97 MB +37 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 19.4 ms 29.1 ms +9.8 ms
CLI --help 37.6 ms 57.4 ms +19.8 ms

@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready at a2138a5. The generated Swift error-code enums look correct, and all 26 checks pass, including the new runner-error-codes gate in repo-guards and the Apple runner builds that compile RunnerErrorCodes.swift. There are no conflicts. Compile and drift coverage comes from CI.

Not blocking: RUNNER_ERROR_CODES and RUNNER_PASS_THROUGH_CODES are exported from packages/apple-runner/src/index.ts only for the generator script, so you could keep them or import runner-contract.ts directly in the generator and drop the two exports. Also, the per-code doc comments on the old Swift enum in RunnerTests.swift are gone, so if any of that prose is not on its RUNNER_ERROR_CODES row, move it there. You can take or leave both.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 20, 2026
…eir table rows

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@thymikee

Copy link
Copy Markdown
Member Author

Follow-up on the two optional notes at 389f37f083:

  • Direct import of runner-contract.ts: not applied. I tried it; layering rule R11 (package-boundaries) rejects ../packages/apple-runner/src/runner-contract.ts from scripts/ and asks for the package specifier. The package has only the . entry, so avoiding the two index exports would need a new subpath export. scripts/check-packaged-runner-swift.ts already imports from the same index, so I kept that pattern.
  • Per-code comments: six rows had lost the note their Swift constant carried (COMMAND_ALREADY_FINISHED, ALERT_UNRESOLVED, both SYNTHESIZED_GESTURE_*, BACK_SWIPE_NO_CHANGE, BACK_SWIPE_UNVERIFIED). They are back on the table rows. Comment-only change; the generated Swift file is unchanged.

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 389f37f

Since the review of a2138a5: 0 new · 0 still open · 0 no longer raised

No open findings.

1 finding below minor hidden (user_settings.min_severity).

1 new finding away from what changed since a2138a5 not shown. Comment @apex-sentinel-staging review for a full review.

Reviewed with this repository's own Sentinel configuration (bfc09800bd5b).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@thymikee
thymikee merged commit 520e2ca into main Nov 20, 2026
25 checks passed
@thymikee
thymikee deleted the t3/generate-swift-runner-error-codes branch November 20, 2026 14:39
thymikee added a commit that referenced this pull request Nov 20, 2026
* origin/main:
  refactor(apple-runner): generate the Swift runner error-code enums from runner-contract.ts (#4810)
  fix(daemon-client): report a newer daemon that won a startup race as daemon-incompatible (#4801)
  feat(shake): add a shake command for iOS simulators and Android emulators (#4741)
  fix(daemon): give a closing daemon its full teardown before anything kills it (#4806)
  fix(android): use typed evidence in the readiness boot poller (#4717)
thymikee added a commit that referenced this pull request Nov 20, 2026
* origin/main:
  refactor(command-surface): split the system family by command (#4817)
  docs(agents): ask PR bodies for before/after and refactor value, not a file count (#4818)
  refactor(apple-runner): generate the Swift runner error-code enums from runner-contract.ts (#4810)
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