Compare commits

...
Author SHA1 Message Date
hanzo-dev b7129f9cae spike: a plugin that serves ZAP ops without the host library
plugin/thinspike is plugin/x402's three moves — serve a typed op, ask a
peer, listen — with the cloud contract removed. It is a measurement, not a
migration: the delta against plugin/x402 is exactly what
Mount(cloud.Router, cloud.Deps) + cloud.Listen cost.

  plugin/x402       602 packages   33.0 MB   3.64s
  plugin/thinspike  355 packages   14.3 MB   1.05s

355 is 3 packages above the floor, and the floor is zip itself (352). So
the cloud contract is 247 packages of the 602 and every one of them can
go; fiber is 242 of the remaining 352 and none of them can, because zip's
root package imports fiber directly. thinspike imports no cloud and still
links fiber/v3.

Co-authored-by: Hanzo Dev <dev@hanzo.ai>
2026-08-04 19:48:45 -07:00
+46
View File
@@ -0,0 +1,46 @@
// Command thinspike is the architecture spike: a plugin that serves its own
// typed ops over ZAP/UDS and calls a peer, importing NO cloud root package.
//
// It is shaped like plugin/x402 — same three moves (serve typed ops, ask a
// peer, listen) — with the cloud contract removed, so the delta between this
// binary's dependency closure and plugin/x402's is exactly the cost of
// Mount(cloud.Router, cloud.Deps) + cloud.Listen.
package main
import (
"context"
"fmt"
"os"
"github.com/hanzoai/cloud/plane"
"github.com/zap-proto/zip"
)
type QuoteIn struct {
Resource string `json:"resource"`
}
type QuoteOut struct {
Decimal string `json:"decimal"`
Currency string `json:"currency"`
}
func main() {
app := zip.New(zip.Config{AppName: "thinspike"})
// Serve a typed op — the ONE value every projection reads.
zip.Post(app, "/v1/thinspike/quote", func(ctx context.Context, in *QuoteIn) (*QuoteOut, error) {
// Call a peer over its canonical socket. No address, no discovery,
// no hand-written client, no peer constant from a fat root package.
out, err := zip.Ask[plane.PriceIn, plane.Priced](
ctx, "marketplace", plane.MarketPrice, &plane.PriceIn{Resource: in.Resource})
if err != nil {
return nil, err
}
return &QuoteOut{Decimal: out.Amount.Decimal, Currency: out.Amount.Currency}, nil
})
if err := app.Listen(zip.Addr("")); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}