Files
zeekayandGitHub f4d6540e6c feat(base): cloud.Mount entry point per HIP-0106 (#4)
* feat(base): cloud.Mount entry point per HIP-0106

Adds pkg/base/mount.go exposing the canonical
Mount(app *zip.App, deps cloud.Deps) error contract. cmd/cloud imports
this package via the blank-import side-effect; init() registers base
with cloud.Registry at order 60 — after iam (50) and kms (10) so the
per-tenant SQLite substrate is up before subsystems that need it.

The mount strategy is "wrap, don't rewrite": Mount constructs a Base
instance with the per-deployment data dir, runs the existing Bootstrap
(data + aux DB, migrations, cached collections, settings reload),
builds the http.Handler from apis.NewRouter(app).BuildMux(), and
attaches it under /v1/base/* + /healthz via zip's net/http adaptor.
/v1/base/health and /v1/base/readyz are native zip handlers so probes
work even when Bootstrap refuses to boot.

DATA_DIR and BASE_API_PREFIX env vars are set inside Mount so Base's
NewWithConfig path picks up the cloud-scoped data directory and the
/v1/base prefix without any flag wiring.

go.mod gains require + replace stanzas for hanzoai/cloud and
hanzoai/zip; matches the kms / vfs convention. The standalone base
binary is unchanged.

schema/base.zap declares the minimum ZAP-typed surface (Health) needed
by the Mount contract; richer ZAP handlers will land alongside the
in-process BaseClient interface from cloud/pkg/cloud/deps.go.

* refactor: collapse pkg/base/ → root for clean import path

Subsystem code lives in package base at repo root. Importers now use
`github.com/hanzoai/base` (no /pkg/base/ nesting). Standalone shim moved
to cmd/base/ where applicable.

Per Hanzo Go-stdlib pattern: repo IS the package.

* refactor: flatten import path — github.com/hanzoai/cloud (drop /pkg/cloud)
2026-05-18 23:40:06 -07:00

34 lines
1.5 KiB
Plaintext

# Hanzo Base — ZAP Schema
#
# Server: base (Go) at base.hanzo.svc.cluster.local or via the unified
# cloud binary at api.hanzo.ai/v1/base.
#
# This schema is the minimum ZAP-typed public surface needed for the
# HIP-0106 Mount() contract. The full HTTP surface — per-tenant SQLite
# CRUD, settings, backups, files, realtime, batch, collection import,
# the HIP-0105 extension runtime substrate — is registered in apis/
# and remains the source of truth for /v1/base/* routes. Wider ZAP-typed
# handlers (Open, Query, Subscribe, …) will land as separate schema PRs
# alongside the in-process BaseClient interface from
# cloud/pkg/cloud/deps.go.
#
# Code generation:
# zapc generate schema/base.zap --lang go --out ./gen/zap/
# zapc generate schema/base.zap --lang ts --out ./gen/zap/
# ── Health ────────────────────────────────────────────────────────────────
struct HealthRequest
# No fields. Probe is a side-effect-free GET.
struct HealthResponse
status Text
service Text
# ── Service interface ────────────────────────────────────────────────────
interface BaseService
# Liveness probe. Always answers ok unless the process is unreachable.
# Mounted at GET /v1/base/health by Mount(app, deps).
health (request HealthRequest) -> (response HealthResponse)