Skip to content

fix(sdk-python): version ldflag + wrong-platform validation (PILOT-208 A+B)#5

Merged
TeoSlayer merged 1 commit into
mainfrom
fix/pilot-208-side-issues-064854
May 29, 2026
Merged

fix(sdk-python): version ldflag + wrong-platform validation (PILOT-208 A+B)#5
TeoSlayer merged 1 commit into
mainfrom
fix/pilot-208-side-issues-064854

Conversation

@TeoSlayer
Copy link
Copy Markdown
Contributor

Two of three PILOT-208 sub-fixes. Third (root cause: CI single-arch publish) stays blocked on PILOT-113 policy.

A — build-binaries.sh missing -X main.Version: binaries reported "dev" at runtime. Added -X main.Version=$SDK_VERSION to all 4 go build lines.

B — wrong-platform wheel produced opaque Exec format error: _validate_binary_platform sniffs the first 4 bytes of a bundled binary, compares to host platform (Linux/Darwin/Windows), raises a typed OSError with reinstall guidance if a KNOWN binary format doesn't match. Unrecognized headers pass through (preserves existing forgiving behavior for test stubs and missing libs).

Blast radius: small. Both changes are additive. A is pure build-time metadata. B raises only on confirmed wrong-platform binary — files with unrecognized headers go through the existing seeder path unchanged (validated by the test suite's missing-lib stub test).

Verification: 55/55 sdk-python tests pass. New code at 97% coverage.

Closes PILOT-208 (partially — A+B; root cause stays blocked).

…8 side fixes)

Two of three sub-fixes from PILOT-208. The third (CI publish-pipeline
single-arch upload) remains blocked on the .github/workflows/ policy
decision tracked in PILOT-113.

Fix A: build-binaries.sh missing version ldflag
  `go build -ldflags="-s -w"` produced binaries that report "dev" for
  their version string at runtime. Added `-X main.Version=$SDK_VERSION`
  (SDK_VERSION is already parsed from pyproject.toml earlier in the
  script) so the four CLI binaries embed the wheel's version. The CGO
  binding doesn't have a main package — left alone.

Fix B: _runtime.py wrong-platform validation
  Wheel bundled binaries get exec'd by cli.py / loaded by client.py.
  If pip installed a wrong-platform wheel (e.g. linux wheel on macOS),
  the failure surfaces as opaque "Exec format error" at first exec
  with no actionable diagnostic. Added _validate_binary_platform that
  sniffs the first 4 bytes of pilotctl for ELF / Mach-O / PE magic,
  compares to host platform, raises OSError with reinstall hint if
  there's a clear mismatch.

  Tightened to raise ONLY when a KNOWN binary format is detected that
  doesn't match — files with unrecognized headers (text stubs, empty
  files in test fixtures) pass through to the existing seeder pipeline
  unchanged. Caught by the existing
  test_missing_lib_does_not_crash_seeder test which was failing on
  the strict initial version.

Verification: 55/55 sdk-python tests pass. _runtime.py coverage at 97%.

Closes PILOT-208 (partially — sub-fixes A + B; root cause stays blocked).
@codecov
Copy link
Copy Markdown

codecov Bot commented May 29, 2026

Codecov Report

❌ Patch coverage is 75.86207% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pilotprotocol/_runtime.py 75.86% 7 Missing ⚠️

📢 Thoughts on this report? Let us know!

@hank-pilot
Copy link
Copy Markdown

hank-pilot commented May 29, 2026

🤖 Hank — CI status

Classification: real
Run: https://github.com/pilot-protocol/sdk-python/runs/78452369464
At commit: 2667697

The build/test failure is a genuine code defect:

codecov/patch — 75.86% of diff hit (target 99.39%)

@matthew-pilot — fix or comment.

Auto-classified at 2026-05-29T10:50:00Z. Re-runs on next push or check completion.

@TeoSlayer TeoSlayer merged commit 9f079a6 into main May 29, 2026
1 of 2 checks passed
@matthew-pilot matthew-pilot deleted the fix/pilot-208-side-issues-064854 branch May 29, 2026 14:46
@matthew-pilot
Copy link
Copy Markdown
Collaborator

🧹 Matthew cleanup — merged by TeoSlayer at 2026-05-29T14:32:10Z. Branch branch fix/pilot-208-side-issues-064854 deleted.

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.

4 participants