Skip to content

feat(ffi): let a host ask which moss it loaded - #21

Merged
ForeverInLaw merged 1 commit into
mainfrom
feat/moss-version-symbol
Jul 28, 2026
Merged

feat(ffi): let a host ask which moss it loaded#21
ForeverInLaw merged 1 commit into
mainfrom
feat/moss-version-symbol

Conversation

@ForeverInLaw

Copy link
Copy Markdown
Contributor

A host resolves the shared library by path at runtime — mosh via moss-runtime/, mosh-org via --moss-lib/MOSH_ORG_MOSS_LIB, the probe from the directory beside the binary. So an old library sitting next to a new host is an ordinary mistake, and its symptoms are transport bugs the host has no way to attribute to the library.

Nothing exposed the version: not the FFI surface, not GetMeshInfo.

Moss_Version returns the build stamp as a C string (free with Moss_Free). The release workflow now passes -ldflags "-X main.buildVersion=<tag>"; anything built another way reports "dev" rather than claiming a version it cannot know. Callers should treat a missing symbol as "older than v0.8.17".

New symbol only — no existing signature changes, so every current host keeps working untouched.

Tests

  • the default stays "dev", so a hand-built library never claims a release;
  • the linker stamp survives into a real c-shared build — checked against the built artifact, not a test binary, because that is the only place the flag actually applies.

The cgo-in-_test.go route is not available (Go rejects it outright), so the symbol's body is a one-line wrapper over the variable both tests pin.

A host resolves the shared library by path at runtime, so an old library
sitting next to a new host is an ordinary mistake — and its symptoms are
transport bugs the host has no way to attribute. Nothing exposed the version:
not the FFI, not GetMeshInfo.

Moss_Version returns the build stamp. The release workflow passes
-ldflags "-X main.buildVersion=<tag>"; anything built another way reports
"dev" rather than claiming a version it cannot know. Callers should treat a
missing symbol as "older than v0.8.17".

New symbol only — no existing signature changes, so every current host keeps
working untouched.
@ForeverInLaw
ForeverInLaw requested a review from Rxflex as a code owner July 28, 2026 19:26
@ForeverInLaw
ForeverInLaw merged commit 11d8726 into main Jul 28, 2026
2 checks passed
@ForeverInLaw
ForeverInLaw deleted the feat/moss-version-symbol branch July 28, 2026 19:35
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