cloud

package module
v1.785.19 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

README

cloud

Unified Go control plane and binary for the Hanzo platform (HIP-0106).

Status License

Quick start

docker run -p 8080:8080 ghcr.io/hanzoai/cloud:latest

What this is

hanzoai/cloud is one Go binary that mounts every Hanzo subsystem (iam, kms, base, gateway, ai, commerce, vfs, mq, dns, amqp, mcp, o11y, ...) into a single multi-tenant process. Same artifact serves api.hanzo.ai, api.osage.cloud, api.lux.cloud, api.zoo.cloud, and every white-label reseller. Brand, enabled subsystems, and tenant scope are deployment configuration.

Specs

Implements:

  • HIP-0014 Application Deployment
  • HIP-0026 IAM
  • HIP-0027 KMS
  • HIP-0037 AI Cloud Platform
  • HIP-0105 In-Process Extension Runtime
  • HIP-0106 Unified Cloud Binary
  • HIP-0302 Encrypted SQLite + ZapDB Durability

Architecture

                 api.{tenant}.{brand}
                          |
                   hanzoai/cloud (one Go binary)
                          |
   +----------+----------+----------+----------+----------+
   |    iam   |   base   |   kms    |    ai    | gateway  | ...
   |  Mount() |  Mount() |  Mount() |  Mount() |  Mount() |
   +----------+----------+----------+----------+----------+
   per-tenant SQLite (HIP-0302)   |   Hanzo IAM JWKS (HIP-0026)
   replicate -> S3 (HIP-0107)     |   ZAP inter-subsystem RPC

Every subsystem exposes func Mount(app *zip.App, deps cloud.Deps) error. White-label fork pattern: customers fork this repo to launch their own ecosystem.


Hanzo Cloud

The unified Go binary that imports every Hanzo-native subsystem and dispatches requests per deployment configuration. One artifact, many subsystems.

Per HIP-0106.

Subsystems mounted

  • iam — identity & access
  • base — per-tenant SQLite + extension runtimes (per HIP-0105)
  • kms — secrets
  • commerce — checkout, billing, pricing, invoicing (light router; NOT in PCI-DSS scope)
  • ai — LLM control plane / RAG / model hub / MCP management (was hanzoai/cloud pre-rename)
  • gateway — HTTP routing + policy
  • o11y — metrics / traces / logs
  • vfs — virtual filesystem / object-store abstraction
  • mq — message queue
  • dns, amqp, mcp, auto, tasks, ... (full list per HIP-0106)

Deployment modes

Same binary; different startup configuration:

cloud --enable=iam,base,kms,commerce,ai,gateway,o11y --brand=hanzo  --domain=hanzo.ai
cloud --enable=iam,base,kms,commerce,ai,gateway,o11y --brand=osage  --domain=osage.cloud
cloud --enable=iam,base,kms,commerce,ai,gateway,o11y --brand=lux    --domain=lux.cloud
cloud --enable=iam,base,kms,commerce,ai,gateway,o11y --brand=zoo    --domain=zoo.cloud

White-label fork pattern

Customers fork hanzoai/cloud to launch their own ecosystem in one binary. Brand detection, enabled subsystems, ZAP endpoints (payments / vault backends) are all deployment configuration.

Web framework

hanzoai/zip — Sinatra-style Go web framework built on Fiber v3. The ONE Go web framework. No .Fast escape hatch.

Status

Scaffold. The Mount(app, deps) integration for each subsystem lands per HIP-0106's migration phases.

Documentation

Overview

Package cloud is the unified Hanzo Cloud binary per HIP-0106.

One Go binary mounts every Hanzo-native subsystem (iam, base, kms, commerce, ai, gateway, o11y, vfs, mq, dns, amqp, mcp, ...) via the canonical Mount(app *zip.App, deps cloud.Deps) error contract. Brand, enabled subsystems, and tenant scope are deployment configuration; the binary is the same artifact across every white-label deployment.

Per HIP-0106 — github.com/hanzoai/HIPs/blob/main/HIPs/hip-0106-unified-hanzo-cloud-binary.md.

Index

Constants

This section is empty.

Variables

View Source
var Registry []MountSpec

Registry is the in-process subsystem registry. Subsystems register via init() functions in their respective packages OR cmd/cloud/main.go can explicitly enumerate them. Either pattern works.

Functions

func MountAll

func MountAll(app any, cfg *Config, deps Deps) error

MountAll iterates the registry in order and calls Mount() on each enabled subsystem.

func Register

func Register(name string, order int, mount MountFunc)

Register adds a subsystem to the in-process registry.

func Serve

func Serve(enable []string) error

Serve boots the canonical compose root and mounts the selected subsystems.

This is the ONE place the cloud-server body lives. cmd/cloud (the full fused surface) and every `hanzo <svc>` subcommand share it; no boot logic is duplicated per entrypoint.

enable==nil ⇒ honor cfg.Enable from flags/env (cloud mode; empty = all). enable!=nil ⇒ force exactly that set (single-service mode), overriding --enable so `hanzo kms` is unambiguous.

Serve registers the HIP-0106 liveness contract (GET /v1/<name>/health for every enabled subsystem) before MountAll, runs the canonical middleware pipeline (Recover → RequestID → Logger), and shuts down gracefully on SIGINT/SIGTERM.

Types

type AIClient

type AIClient = types.AIClient

type BaseClient

type BaseClient = types.BaseClient

type ChatRequest

type ChatRequest = types.ChatRequest

type ChatResponse

type ChatResponse = types.ChatResponse

type Claims

type Claims = types.Claims

type CommerceClient

type CommerceClient = types.CommerceClient

type Config

type Config struct {
	// Enable lists subsystems to mount this run. Empty = all enabled.
	// Example: --enable=iam,base,kms,commerce,ai,gateway,o11y
	Enable []string

	// Brand is the white-label brand identifier.
	Brand string

	// Domain is the deployment's primary public domain.
	Domain string

	// IAMIssuer is the JWKS issuer for JWT validation (usually iam.hanzo.ai).
	IAMIssuer string

	// KMSMasterKeyRef points at the KMS master key for per-tenant DEK derivation.
	KMSMasterKeyRef string

	// DataDir is the on-disk data root.
	DataDir string

	// ListenAddr is the public HTTP listener (default :8080).
	ListenAddr string

	// ZAPListenAddr is the ZAP-RPC listener (default :9653).
	ZAPListenAddr string

	// HealthListenAddr is the health/metrics listener (default :9090).
	HealthListenAddr string

	// AdminListenAddr is the admin endpoint (default :8081, gated by IAM admin).
	AdminListenAddr string

	// Endpoints for out-of-process subsystems (payments, vault). Empty
	// means the subsystem is disabled OR the deployment expects a default
	// service-discovery resolution.
	PaymentsZAPAddr string
	VaultZAPAddr    string

	// ZAP RPC endpoints for subsystems that are NOT enabled in this
	// process but are still needed by an enabled subsystem. Empty
	// means "no remote endpoint" — the client falls back to the
	// disabled stub which fails closed with a clear error.
	//
	// Convention: <subsystem>.<env>.<deployment>.svc:9653 — the same
	// inter-subsystem listener port the unified binary exposes. The
	// transport is hanzoai/zap, never JSON.
	IAMZAPAddr      string
	KMSZAPAddr      string
	BaseZAPAddr     string
	CommerceZAPAddr string
	AIZAPAddr       string
	O11yZAPAddr     string
	VFSZAPAddr      string
	MQZAPAddr       string
}

Config is the cloud binary's startup configuration. Drives which subsystems mount, what brand surface to serve, and where data lives.

func LoadConfig

func LoadConfig() *Config

LoadConfig reads flags + env into a Config. Flags override env.

func (*Config) Enabled

func (c *Config) Enabled(name string) bool

Enabled reports whether subsystem `name` is enabled in this config. Empty Enable list = all subsystems enabled.

func (*Config) Validate

func (c *Config) Validate() error

Validate returns an error if the config is missing required values.

type Counter

type Counter = types.Counter

type DBHandle

type DBHandle = types.DBHandle

type Deps

type Deps struct {
	// Logger is the canonical Hanzo logger (luxfi/log). Subsystems derive
	// scoped child loggers from this.
	Logger luxlog.Logger

	// Brand is the white-label brand identifier for this deployment.
	// Values: "hanzo", "lux", "zoo", "osage", "pars", or any customer brand.
	Brand string

	// Domain is the deployment's primary domain (e.g. "api.hanzo.ai",
	// "api.osage.cloud"). Subsystems use this to scope URLs in responses.
	Domain string

	// DataDir is the per-deployment data root. Per-tenant SQLite files
	// land at {DataDir}/orgs/{orgSlug}/{service}.db per HIP-0302.
	DataDir string

	// Subsystem clients — populated by BuildDeps based on enabled subsystems.
	// Each is an interface with both in-process and ZAP-RPC implementations.
	IAM      IAMClient
	KMS      KMSClient
	Base     BaseClient
	Commerce CommerceClient
	AI       AIClient
	O11y     O11yClient
	VFS      VFSClient
	MQ       MQClient

	// Payments + Vault stay out-of-process (PCI scope isolation per
	// HIP-0106). These clients always resolve to ZAP-RPC implementations,
	// never in-process.
	Payments PaymentsClient
	Vault    VaultClient
}

Deps is the shared dependency surface passed to every subsystem's Mount(app, deps) function. Subsystems consume only what they need.

In-process: each Client below resolves to a direct Go method-call implementation. Out-of-process (legacy split deploys): the same Client resolves to a ZAP-RPC implementation. Subsystem code does not branch on which mode; the interface is the contract.

func BuildDeps

func BuildDeps(cfg *Config) Deps

BuildDeps constructs the Deps used by every subsystem's Mount(app, deps).

Wiring rules per HIP-0106 inter-subsystem contract:

  1. If the subsystem is enabled in this process, the Client field is left nil here. The subsystem's own Mount() will install a typed in-process Client into Deps via the SetClient helpers exposed by this package. (Subsystem Mounts run after BuildDeps; they have full access to construct their concrete implementation, and the resulting object goes back into Deps for everyone else to call.)

  2. If the subsystem is disabled but cfg has a non-empty ZAP RPC endpoint for it, the Client field gets a ZAP-RPC stub targeting that endpoint. Subsystem code calls deps.X.Foo(...) without knowing the call goes over the wire.

  3. If the subsystem is disabled AND there is no endpoint, the Client field gets a "disabled" stub that fails closed with a clear error. Mount-time consumers detect this with clients.IsDisabled(err) and log a friendly "dep X needed by Y not configured" message.

JSON does not appear in any of these paths. Inter-subsystem calls are ZAP-typed Go values either via direct method dispatch (mode 1) or via ZAP RPC over the wire (mode 2). JSON happens only at the gateway/ingress edge, through the hanzoai/zip jsonenc helper.

Payments and Vault are special: they are NEVER in-process per HIP-0106 solo-vault CDE. Their clients always resolve via clients.PaymentsRPCAt / clients.VaultRPCAt; the disabled stub fires when no endpoint is configured.

type IAMClient

type IAMClient = types.IAMClient

type IntentRequest

type IntentRequest = types.IntentRequest

type IntentResponse

type IntentResponse = types.IntentResponse

type IntentStatus

type IntentStatus = types.IntentStatus

type KMSClient

type KMSClient = types.KMSClient

type LicenseEntitlement

type LicenseEntitlement = types.LicenseEntitlement

type MQClient

type MQClient = types.MQClient

type MountFunc

type MountFunc func(app any, deps Deps) error // app is *zip.App; using any here to avoid an import cycle in pkg/cloud

MountFunc is the canonical signature every subsystem exposes per HIP-0106. Each Hanzo Go service ships a top-level `Mount` symbol matching this signature; cmd/cloud/main.go imports the package and calls it.

type MountSpec

type MountSpec struct {
	Name  string
	Order int
	Mount MountFunc
}

MountSpec describes one subsystem registered for mounting. The Order is used when ordering matters for inter-subsystem deps (e.g. iam before authz before commerce).

type O11yClient

type O11yClient = types.O11yClient

type Org

type Org = types.Org

type PaymentsClient

type PaymentsClient = types.PaymentsClient

type Span

type Span = types.Span

type TenantConfig

type TenantConfig = types.TenantConfig

type Timing

type Timing = types.Timing

type User

type User = types.User

type VFSClient

type VFSClient = types.VFSClient

type VaultChargeRequest

type VaultChargeRequest = types.VaultChargeRequest

type VaultChargeResponse

type VaultChargeResponse = types.VaultChargeResponse

type VaultClient

type VaultClient = types.VaultClient

Directories

Path Synopsis
Package clients holds the canonical ZAP-typed inter-subsystem clients used by cloud.Deps.
Package clients holds the canonical ZAP-typed inter-subsystem clients used by cloud.Deps.
gojahost
Package gojahost runs a Hanzo Node service's goja bundle (a self-contained, ESM-free JS file exposing globalThis.handle(req)) inside the unified cloud binary, per HIP-0106.
Package gojahost runs a Hanzo Node service's goja bundle (a self-contained, ESM-free JS file exposing globalThis.handle(req)) inside the unified cloud binary, per HIP-0106.
plansvc
Package plansvc mounts the @hanzo/plans catalog into the unified cloud binary under /v1/plans/*, per HIP-0106.
Package plansvc mounts the @hanzo/plans catalog into the unified cloud binary under /v1/plans/*, per HIP-0106.
pricingsvc
Package pricingsvc mounts the @hanzo/pricing service into the unified cloud binary under /v1/pricing/* (+ the /v1/models, /v1/gpu, /v1/tools aliases), per HIP-0106.
Package pricingsvc mounts the @hanzo/pricing service into the unified cloud binary under /v1/pricing/* (+ the /v1/models, /v1/gpu, /v1/tools aliases), per HIP-0106.
cmd
cloud command
cloud is the unified Hanzo Cloud binary per HIP-0106.
cloud is the unified Hanzo Cloud binary per HIP-0106.
hanzo command
Command hanzo is the unified Hanzo Go binary, dispatched by subcommand.
Command hanzo is the unified Hanzo Go binary, dispatched by subcommand.
Package subsystems is the single source of truth for which Hanzo cloud subsystems are linked into a binary.
Package subsystems is the single source of truth for which Hanzo cloud subsystems are linked into a binary.
Package types holds the placeholder transport types AND the inter-subsystem client interfaces shared between cloud (the orchestrator) and cloud/clients (the in-process and RPC client implementations).
Package types holds the placeholder transport types AND the inter-subsystem client interfaces shared between cloud (the orchestrator) and cloud/clients (the in-process and RPC client implementations).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL