mirror of
https://github.com/hanzoai/team-go.git
synced 2026-10-30 20:22:42 +00:00
The Go transactor and account service for Hanzo Team. History starts here. The previous 107 commits carried the fork's origin in their messages and their tree, and none of it described this code: the Go under pkg/transactor is Hanzo's own work implementing a wire protocol, not a port of anyone's implementation. pkg/transactor/model.json remains, and remains attributed. It is a compiled platform model this transactor loads through go:embed, governed by EPL-2.0 and named in NOTICE. Removing it is a replacement project -- a new compiler and a move off the protocol -- not a deletion.
52 lines
1.7 KiB
Go
52 lines
1.7 KiB
Go
// Package model owns the platform MODEL version — the single number the
|
|
// front SPA handshakes against.
|
|
//
|
|
// This is DISTINCT from TEAM_VERSION (team-go's own release/commit, surfaced on
|
|
// /v1/health and Prometheus). Two concepts that were previously conflated:
|
|
//
|
|
// - TEAM_VERSION — the running binary's release identity (health, metrics).
|
|
// - MODEL_VERSION — the model the front validates against (transactor
|
|
// hello's serverVersion + each workspace's versionMajor/Minor/Patch).
|
|
//
|
|
// Both places that answer the front's model-version handshake read from HERE,
|
|
// so serverVersion and the per-workspace version can never drift: one source,
|
|
// one number, parsed one way.
|
|
package model
|
|
|
|
import (
|
|
"os"
|
|
"strconv"
|
|
"strings"
|
|
)
|
|
|
|
// DefaultVersion is the front SPA's current model version. Shipping it as the
|
|
// code default keeps the binary in sync with the front with no configuration —
|
|
// MODEL_VERSION exists only to fast-track a front bump ahead of a team-go
|
|
// release.
|
|
const DefaultVersion = "0.6.0"
|
|
|
|
// Version is the MODEL version string (e.g. "0.6.0"), overridable via
|
|
// MODEL_VERSION.
|
|
func Version() string {
|
|
if v := os.Getenv("MODEL_VERSION"); v != "" {
|
|
return v
|
|
}
|
|
return DefaultVersion
|
|
}
|
|
|
|
// Major, Minor and Patch are Version parsed into its numeric components — the
|
|
// shape the workspace-info handshake needs. A missing or non-numeric component
|
|
// reads as 0, so a malformed override degrades to 0.0.0 rather than panicking.
|
|
func Major() int { return part(0) }
|
|
func Minor() int { return part(1) }
|
|
func Patch() int { return part(2) }
|
|
|
|
func part(i int) int {
|
|
segs := strings.SplitN(Version(), ".", 3)
|
|
if i >= len(segs) {
|
|
return 0
|
|
}
|
|
n, _ := strconv.Atoi(strings.TrimSpace(segs[i]))
|
|
return n
|
|
}
|