Skip to content

fix(ant-dev): dispatcher swift no-skip + lua LUA_PATH wrap#86

Merged
Nic-dorman merged 1 commit into
mainfrom
fix/dispatcher-swift-and-lua
May 14, 2026
Merged

fix(ant-dev): dispatcher swift no-skip + lua LUA_PATH wrap#86
Nic-dorman merged 1 commit into
mainfrom
fix/dispatcher-swift-and-lua

Conversation

@Nic-dorman

Copy link
Copy Markdown
Collaborator

Summary

Two dispatcher bugs surfaced by running ant dev example data -l <lang> across all 15 SDKs on a Linux dev box (the cross-SDK e2e harness on dev2):

swift — silently auto-skipped

The adapter shipped with skip_reason="REST/gRPC SDK is macOS-only per antd-swift README", so swift never ran in any sweep. The README claim is stale — the swift.org Linux toolchain (6.0.x) builds and round-trips against antd end-to-end with the patches in the companion antd-swift PR. Replace the skip with a real adapter that runs swift run AntdExamples N, mirroring csharp/kotlin's number-arg pattern.

lua — module 'antd' not found

luarocks --local --lua-version=5.4 make installs to ~/.luarocks/share/lua/5.4/antd/, which lua5.4 doesn't pick up by default. The adapter called lua5.4 examples/02-data.lua directly, so the example fataled at require('antd'). Wrap the run via bash -c 'eval "$(luarocks --local --lua-version=5.4 path)" && exec lua5.4 "examples/$1"' so the freshly-installed rock is on LUA_PATH/LUA_CPATH for the subprocess.

Filename is sourced from the static examples dict and passed as a positional arg to the inner shell — no string interpolation into the command line.

Test plan

Verified on Linux (Ubuntu 24.04, Swift 6.0.3, Lua 5.4) with all 15 SDKs:

  • ant dev example data -l swift — round-trip OK, real estimate fields populated (no skip)
  • ant dev example data -l lua — round-trip OK ("Public data round-trip OK!")
  • Full 15-SDK sweep: 15/15 green, 0 skips
  • No behavioural change to the other 13 adapters

Related

Companion PR adds the antd-swift Linux-port patches the swift adapter relies on (Package.swift bump to grpc-swift 2.x, FoundationNetworking import, override on error subclass inits, CostDTO snake_case decoding fix). Either PR can land first — without the antd-swift patches, the swift adapter will fail at compile, but lua + the other 13 are unaffected.

🤖 Generated with Claude Code

Two unrelated dispatcher bugs surfaced when running the full
`ant dev example data -l <lang>` sweep across all 15 SDKs on Linux.

## swift

The adapter shipped with `skip_reason="REST/gRPC SDK is macOS-only per
antd-swift README"`, so swift was silently auto-skipped on every run.
The README claim is outdated — the swift toolchain on Linux (swift.org
release, 6.0.x) builds and round-trips against antd end-to-end. Replace
the skip with a real adapter that runs `swift run AntdExamples N`,
mirroring the csharp/kotlin number-arg pattern.

## lua

`luarocks --local --lua-version=5.4 make` installs the rock under
`~/.luarocks/share/lua/5.4/antd/`, which `lua5.4` doesn't pick up by
default. The adapter just called `lua5.4 examples/02-data.lua`, so the
example fataled with `module 'antd' not found`. Wrap the run via
`bash -c 'eval "$(luarocks --local --lua-version=5.4 path)" && exec
lua5.4 "examples/$1"'` so the freshly-installed rock is on
LUA_PATH/LUA_CPATH for the subprocess.

Filename comes from the `examples` dict (static), passed as a positional
arg to the inner shell — no string interpolation into the command line.

## Test plan

Verified end-to-end on a Linux dev box (Ubuntu 24.04, Swift 6.0.3,
Lua 5.4):

- [x] `ant dev example data -l swift` — round-trip OK, real
      `Estimate: 24 bytes in 3 chunks, ...` (no skip)
- [x] `ant dev example data -l lua` — round-trip OK
      ("Public data round-trip OK!")
- [x] Other 13 SDKs unchanged (cpp/csharp/dart/elixir/go/java/js/
      kotlin/php/python/ruby/rust/zig) — full sweep 15/15 green

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Nic-dorman
Nic-dorman merged commit b5a7830 into main May 14, 2026
@Nic-dorman
Nic-dorman deleted the fix/dispatcher-swift-and-lua branch May 14, 2026 13:02
Nic-dorman added a commit that referenced this pull request May 14, 2026
The Swift SDK is documented as macOS-only in `antd-swift/README.md`, but
in practice the swift.org Linux toolchain (6.0.x) builds and round-trips
against antd end-to-end after a small set of upstream-fixable patches.
This PR collects them and adds a snake-case-decoding fix for the cost
estimate that was hiding behind the "macOS-only" framing.

Verified end-to-end on Ubuntu 24.04 with Swift 6.0.3:
`swift build && swift run AntdExamples 2` → "Public data round-trip OK!"
with real `Estimate: 24 bytes in 3 chunks, storage 43945312500000000
atto, gas 150000000000000 wei, mode single`.

## Changes

### Package.swift — bump grpc-swift to 2.x

`grpc-swift-protobuf 1.x` requires Swift tools 6.0+, which conflicts
with the previous `from: "1.23.0"` pin on `grpc-swift` (which is on the
1.x line, requiring 5.x tooling). Bump `grpc-swift` to `2.0.0` and add
the new `grpc-swift-nio-transport` package — `GRPCNIOTransportHTTP2`
moved out of the main grpc-swift repo in 2.x.

### AntdRestClient.swift — three fixes

1. **`FoundationNetworking` import** — Linux builds split URLSession out
   of `Foundation` into a separate `FoundationNetworking` module.
   Guarded with `#if canImport(...)` so macOS/iOS are unaffected.
2. **PUT-response cost is optional** — daemon's `POST /v1/data/public`,
   `/v1/data/private`, `/v1/chunks` currently return `{address,
   chunks_stored, payment_mode_used}` without `cost`, so the previous
   `let cost: String` decoder fataled. Mirrors the antd-php / antd-py
   fallback to empty-string. Same shape addressed in #77 (kotlin) and
   the long-standing PHP/Python pattern.
3. **CostDTO snake_case decoding** — the bug hidden by today's e2e:
   `JSONDecoder.snakeCase` (which is `keyDecodingStrategy =
   .convertFromSnakeCase`) converts JSON `file_size` → expected Swift
   property `fileSize`. CostDTO had snake_case property names, so
   decoding silently nilled them out and `dataCost` / `fileCost` always
   returned zero for `fileSize`/`chunkCount`/`gas`/`mode`. Rename to
   camelCase so the decoder matches.

### Errors.swift — `override` keyword on subclass inits

Swift 6's stricter init resolution flagged the 9 error subclass
initializers as missing `override` against `AntdError.init(_:statusCode:)`.
Add the keyword.

### AntdExamples/Main.swift — Linux-safe minimal example

The previous bundled example used `SecRandomCopyBytes` from Apple's
`Security` framework (macOS-only) and had pre-existing arity bugs in
several of the per-example helper functions. Replace with a minimal
Linux-portable example 02 that exercises the public data round-trip and
exits non-zero on mismatch — enough for cross-SDK e2e validation. The
full example suite would be a separate restoration once
`SecRandomCopyBytes` is replaced and the arity bugs are fixed.

## Test plan

- [x] `cd antd-swift && swift build` clean on Ubuntu 24.04 with Swift
      6.0.3 (one cosmetic warning: `dependency 'grpc-swift' is not used
      by any target` — only the nio-transport sub-package is used)
- [x] `swift run AntdExamples 2` against a local devnet — round-trip OK,
      real estimate fields
- [x] Cross-SDK e2e harness: 15/15 SDKs pass, swift no longer skipped

## Companion PR

PR adding `swift run AntdExamples N` to the `ant dev example`
dispatcher (and removing the `skip_reason` that was auto-skipping
swift) is in #86. Either can land first; without the antd-swift
patches here, the dispatcher's swift adapter will fail at compile.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Nic-dorman added a commit that referenced this pull request May 14, 2026
Cuts v0.7.1 atop v0.7.0. Primarily refreshes the upstream `ant-core`
pin to the `ant-cli-v0.2.3` release tag (no API change for antd
consumers). Bundles a substantial round of cross-SDK example/build
fixes, dispatcher improvements, and CI/release workflow hardening.

## antd

- chore(antd): bump ant-core to v0.2.3 (#85)

## SDK example/build fixes

- fix(antd-php): use cost-estimate fields in example 02 (#74)
- fix(antd-elixir): print cost-estimate fields in examples (#75)
- fix(antd-lua): add missing discover module to rockspec (#76)
- fix(antd-kotlin): make put-response cost optional + ship gradle wrapper (#77)
- fix(antd-zig): pass payment_mode to dataPutPublic/dataPutPrivate (#79)
- fix(antd-java): make examples runnable via gradle :examples subproject (#80)
- fix(antd-zig): align stdlib API to declared 0.14.x minimum (#82)
- fix(antd-swift): port to Linux + populate cost-estimate fields (#87)

## ant-dev (developer CLI)

- fix(ant-dev): clean up orphan anvil/antnode and stale node identities on stop (#81)
- fix(ant-dev): tooling cluster — flag alias, sys.executable, anvil preflight, README (#83)
- feat(ant-dev): expand `ant dev example` to dispatch all 15 SDKs (#84)
- fix(ant-dev): dispatcher swift no-skip + lua LUA_PATH wrap (#86)
- feat(ant-dev): expose --preset flag on `ant dev start` (default: small) (#88)

## CI / release

- ci: authenticate arduino/setup-protoc on ci.yml too (#60)
- feat(release): publish antd-linux-arm64 artifact (#89)

## Validation

15/15 SDKs round-tripped end-to-end against a daemon built from this
commit on a Linux dev box (Ubuntu 24.04, 0.7.1 atop ant-core v0.2.3).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant