Files
skills/public/hip-0106.html
zeekayandHanzo Dev 9e10c1c10e Each llms index points at the other two
hanzoskills.com/llms.txt now opens with the install line, the API
reference index and the company index, so an agent that lands on any
one of the three can find the rest.

robots.txt claimed 537 documents while llms.txt counts 920. The number
is gone from robots.txt; llms.txt derives it.

public/ is regenerated from scripts/site.py, which it had fallen
behind: the copy-prompt menu and agent bar were in the generator and
not in the committed pages. tests/site.mjs passes against the result.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-11 00:27:59 -07:00

741 lines
97 KiB
HTML

<!doctype html>
<html lang="en"><head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>hip-0106</title>
<meta name="color-scheme" content="dark">
<style>
/* Committed to one visual world: a dark instrument panel. No light variant —
the dot field and the hairline rules only read on black, and a naive
inversion would wash both out. Every colour is painted explicitly so the page
never borrows a host background. */
@font-face{font-family:'Zen';src:url('/fonts/Zen-Variable.woff2') format('woff2');font-weight:100 900;font-style:normal;font-display:swap}
@font-face{font-family:'Zen';src:url('/fonts/Zen-Italic-Variable.woff2') format('woff2');font-weight:100 900;font-style:italic;font-display:swap}
@font-face{font-family:'Zen Mono';src:url('/fonts/ZenMono-Variable.woff2') format('woff2');font-weight:100 900;font-style:normal;font-display:swap}
@font-face{font-family:'Zen Mono';src:url('/fonts/ZenMono-Italic-Variable.woff2') format('woff2');font-weight:100 900;font-style:italic;font-display:swap}
@font-face{font-family:'Zen Pixel Square';src:url('/fonts/ZenPixel-Square.woff2') format('woff2');font-style:normal;font-display:swap}
:root{
--ink:#f4f4f2; --soft:#9c9c98; --faint:#6a6a66; --ground:#000; --panel:#0a0a0a;
--line:#232323; --line-hi:#3a3a3a; --accent:#f4f4f2;
--font-zen-sans:'Zen',-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif;
--font-zen-mono:'Zen Mono',ui-monospace,"SF Mono",SFMono-Regular,Menlo,Consolas,monospace;
--font-zen-pixel-square:'Zen Pixel Square',monospace;
--mono:var(--font-zen-mono);
--sans:var(--font-zen-sans);
/* Controls are pills and surfaces are soft, as on hanzo.ai. */
--r:999px; --r-soft:14px;
}
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{margin:0;background:var(--ground);color:var(--ink);font-family:var(--sans);
font-size:16px;line-height:1.65;-webkit-font-smoothing:antialiased}
.wrap{max-width:60rem;margin:0 auto;padding:0 1.75rem}
/* The dot field. A halftone made of one repeating radial-gradient, faded out
along the diagonal by a mask so it reads as a wave rather than wallpaper. */
/* No overflow clip here: the dot field is inset to the box already, and a clip
would cut off the copy-prompt menu. */
.hero{position:relative;border-bottom:1px solid var(--line)}
.hero::before{content:"";position:absolute;inset:0;
background-image:radial-gradient(var(--line-hi) 1px, transparent 1px);
background-size:7px 7px;
-webkit-mask-image:linear-gradient(115deg,#000 0%,rgba(0,0,0,.55) 38%,transparent 72%);
mask-image:linear-gradient(115deg,#000 0%,rgba(0,0,0,.55) 38%,transparent 72%);
pointer-events:none}
.hero .wrap{position:relative;padding-top:5.5rem;padding-bottom:4rem}
nav{border-bottom:1px solid var(--line)}
nav .in{max-width:60rem;margin:0 auto;padding:1.1rem 1.75rem;display:flex;
justify-content:space-between;align-items:center;gap:1rem}
.brand{font-family:var(--mono);font-size:.85rem;letter-spacing:.14em;
text-transform:uppercase;color:var(--ink);text-decoration:none;
display:inline-flex;align-items:center;gap:.6rem}
.brand i{font-style:normal;color:var(--faint)}
.mark{width:1.15em;height:1.15em;display:block;flex:0 0 auto}
nav a.up{font-family:var(--mono);font-size:.72rem;letter-spacing:.14em;
text-transform:uppercase;color:var(--soft);text-decoration:none}
nav a.up:hover{color:var(--ink)}
h1{font-family:var(--mono);font-size:clamp(2rem,5.4vw,3.4rem);line-height:1.12;
letter-spacing:-.02em;margin:0 0 1.1rem;font-weight:500;text-wrap:balance}
h1 em{font-style:normal;color:var(--faint)}
.lede{color:var(--soft);font-size:1.05rem;max-width:52ch;margin:0 0 2.25rem}
.btns{display:flex;flex-wrap:wrap;gap:.7rem;margin:0 0 .5rem;align-items:center}
.btn{display:inline-flex;align-items:center;gap:.5rem;font-family:var(--mono);
font-size:.72rem;letter-spacing:.14em;text-transform:uppercase;
padding:.8rem 1.4rem;border:1px solid var(--line-hi);border-radius:var(--r);
color:var(--ink);text-decoration:none;background:transparent;cursor:pointer;
line-height:1.2;font-weight:400}
.btn:hover{background:#141414;text-decoration:none;border-color:var(--soft)}
.btn.solid{background:var(--ink);color:#000;border-color:var(--ink)}
.btn.solid:hover{background:#d8d8d4}
.btn .chev{width:.7em;height:.7em;flex:0 0 auto;transition:transform .15s ease}
.btn[aria-expanded="true"] .chev{transform:rotate(180deg)}
/* Copy-prompt selector. Each row copies the prompt for its own target. */
.copy{position:relative;display:inline-flex}
.menu{position:absolute;top:calc(100% + .5rem);left:0;z-index:20;min-width:21rem;
background:var(--panel);border:1px solid var(--line-hi);border-radius:var(--r-soft);
padding:.4rem;display:flex;flex-direction:column;
box-shadow:0 12px 32px rgba(0,0,0,.75)}
.menu[hidden]{display:none}
.mi{display:flex;align-items:center;gap:.7rem;width:100%;text-align:left;
padding:.62rem .8rem;border:0;border-radius:calc(var(--r-soft) - .35rem);
background:transparent;color:var(--ink);font-family:var(--mono);font-size:.76rem;
letter-spacing:.04em;text-decoration:none;cursor:pointer;line-height:1.3;
white-space:nowrap}
.mi:hover,.mi:focus-visible{background:#181818;outline:none}
.mi .mark{width:1.05rem;height:1.05rem;color:var(--soft)}
.mi:hover .mark{color:var(--ink)}
.mi u{margin-left:auto;color:var(--faint);text-decoration:none;font-size:.68rem;
letter-spacing:.1em;text-transform:uppercase}
/* Works-with bar: one scrolling row, name and mark per agent. */
.strip{border-bottom:1px solid var(--line);background:var(--panel)}
.strip .in{max-width:60rem;margin:0 auto;padding:.9rem 1.75rem;display:flex;
align-items:center;gap:1.25rem;font-family:var(--mono);font-size:.72rem;
letter-spacing:.1em;text-transform:uppercase;color:var(--faint)}
.strip b{color:var(--soft);font-weight:400;flex:0 0 auto;
border-right:1px solid var(--line);padding-right:1.25rem;align-self:stretch;
display:flex;align-items:center}
.bar{display:flex;align-items:center;gap:.5rem;flex:1 1 auto;min-width:0;
overflow-x:auto;scrollbar-width:none;scroll-snap-type:x proximity;
-webkit-overflow-scrolling:touch;
-webkit-mask-image:linear-gradient(90deg,#000 calc(100% - 3rem),transparent);
mask-image:linear-gradient(90deg,#000 calc(100% - 3rem),transparent)}
.bar::-webkit-scrollbar{display:none}
.agent{display:inline-flex;align-items:center;gap:.45rem;flex:0 0 auto;
padding:.4rem .85rem;border:1px solid var(--line);border-radius:var(--r);
color:var(--soft);white-space:nowrap;scroll-snap-align:start;
text-decoration:none;background:var(--ground)}
.agent:hover{color:var(--ink);border-color:var(--line-hi);text-decoration:none}
.agent .mark{width:.95rem;height:.95rem}
h2{font-family:var(--mono);font-size:1.1rem;letter-spacing:-.01em;margin:2.75rem 0 .75rem;font-weight:500}
h3{font-size:1rem;margin:2rem 0 .5rem;font-weight:600}
h4,h5,h6{font-size:.94rem;margin:1.5rem 0 .5rem;font-weight:600}
p{margin:0 0 1rem;max-width:70ch}
ul,ol{margin:0 0 1rem;padding-left:1.35rem;max-width:70ch}
li{margin:.22rem 0}
a{color:var(--ink);text-decoration:underline;text-underline-offset:3px;
text-decoration-color:var(--line-hi)}
a:hover{text-decoration-color:var(--ink)}
a:focus-visible{outline:1px solid var(--ink);outline-offset:3px}
code{font-family:var(--mono);font-size:.85em;background:var(--panel);
border:1px solid var(--line);border-radius:5px;padding:.1em .36em}
pre{background:var(--panel);border:1px solid var(--line);padding:1rem 1.1rem;
border-radius:var(--r-soft);overflow-x:auto;margin:0 0 1.25rem}
pre code{background:none;border:0;padding:0;font-size:.82rem;line-height:1.7}
blockquote{margin:0 0 1rem;padding-left:1rem;border-left:1px solid var(--line-hi);color:var(--soft)}
hr{border:0;border-top:1px solid var(--line);margin:2.5rem 0}
table{border-collapse:collapse;width:100%;margin:0 0 1.25rem;font-size:.92rem;
display:block;overflow-x:auto}
th,td{border:1px solid var(--line);padding:.5rem .7rem;text-align:left}
.curl{display:block;background:var(--panel);border:1px solid var(--line);
border-radius:var(--r-soft);padding:.95rem 1.1rem;font-family:var(--mono);
font-size:.8rem;color:var(--soft);overflow-x:auto;margin:0 0 2.5rem;
white-space:pre;line-height:1.9}
.curl b{color:var(--ink);font-weight:400}
.curl i{font-style:normal;color:var(--faint)}
/* index */
#q{width:100%;padding:.85rem 1.2rem;font-family:var(--mono);font-size:.85rem;color:var(--ink);
background:var(--panel);border:1px solid var(--line);border-radius:var(--r);margin:0 0 .6rem}
#q::placeholder{color:var(--faint);text-transform:uppercase;letter-spacing:.1em;font-size:.72rem}
#q:focus{outline:none;border-color:var(--soft)}
#count{color:var(--faint);font-family:var(--mono);font-size:.72rem;letter-spacing:.1em;
text-transform:uppercase;margin:0 0 2rem}
.cat{margin:2.5rem 0 .5rem;font-family:var(--mono);font-size:.7rem;letter-spacing:.16em;
text-transform:uppercase;color:var(--faint);border-bottom:1px solid var(--line);
padding-bottom:.45rem}
.row{display:block;padding:.6rem .9rem;margin:0 -.9rem;border-bottom:1px solid var(--line);
border-radius:var(--r-soft);text-decoration:none}
.row:hover{background:#0a0a0a}
.nm{font-family:var(--mono);font-size:.84rem;color:var(--ink);display:block}
.ds{color:var(--soft);font-size:.9rem;display:block;margin-top:.12rem}
footer{margin-top:4rem;padding:2rem 0 4rem;border-top:1px solid var(--line);
color:var(--faint);font-size:.85rem}
footer a{color:var(--soft)}
.fmap{display:grid;gap:1.75rem;grid-template-columns:repeat(auto-fit,minmax(11rem,1fr));
margin:0 0 2rem;font-size:.85rem}
.fmap b{display:block;font-family:var(--mono);font-size:.68rem;letter-spacing:.16em;
text-transform:uppercase;color:var(--faint);font-weight:400;margin:0 0 .6rem;
border-bottom:1px solid var(--line);padding-bottom:.4rem}
.fmap a{display:inline-block;color:var(--ink);text-decoration:none;margin:.3rem .35rem 0 0}
.fmap a:hover{text-decoration:underline}
.fmap div{color:var(--faint);line-height:1.5}
.fend{border-top:1px solid var(--line);padding-top:1.25rem;font-size:.82rem}
@media (max-width:640px){
.hero .wrap{padding-top:3.25rem;padding-bottom:2.75rem}
.btns{gap:.5rem}
.btn{padding:.75rem 1.15rem;font-size:.68rem}
.copy,.copy .btn{width:100%;justify-content:center}
.menu{left:0;right:0;min-width:0}
.strip .in{flex-direction:column;align-items:flex-start;gap:.6rem;padding:.9rem 1.75rem}
.strip b{border-right:0;padding-right:0}
.bar{width:100%}
}
</style>
<link rel="alternate" type="text/markdown" href="/hip-0106.md">
<link rel="icon" href="/favicon.svg">
<link rel="canonical" href="https://hanzoskills.com/hip-0106">
</head>
<!-- Reading this with a machine? Every page here is also plain markdown.
This one: https://hanzoskills.com/hip-0106.md
Index: https://hanzoskills.com/llms.txt
Corpus: https://hanzoskills.com/all.md
Append .md to any path for the markdown twin. -->
<body>
<nav><div class="in">
<a class="brand" href="/"><svg class="mark" viewBox="0 0 67 67" fill="currentColor" aria-hidden="true"><path d="M22.21 67V44.6369H0V67H22.21Z"/><path d="M66.7038 22.3184H22.2534L0.0878906 44.6367H44.4634L66.7038 22.3184Z"/><path d="M22.21 0H0V22.3184H22.21V0Z"/><path d="M66.7198 0H44.5098V22.3184H66.7198V0Z"/><path d="M66.7198 67V44.6369H44.5098V67H66.7198Z"/></svg> HANZO<i>SKILLS</i></a>
<a class="up" href="/">All skills</a>
</div></nav>
<div class="wrap">
<h1>hip-0106</h1><p class="lede">HIP-106: The Hanzo Plugin Contract. Status Final. Hanzo architectural specification.</p><h1>HIP-0106: The Hanzo Plugin Contract</h1>
<h2>Abstract</h2>
<p>This is the contract a git repository satisfies in order to build and run as a Hanzo plugin: what it may import, what its <code>main</code> does, how it declares the paths it answers, what documents it must project, and what gates prove all of it. Any repository that satisfies it composes into any host — <code>hanzoai/cloud</code> is the reference host — and also runs standalone as an ordinary HIP-0119 service, with no second code path and no build matrix.</p>
<p><strong>A plugin imports <code>zip</code> and nothing of the host&#x27;s.</strong> Its binary is composed at run time, not linked at build time, so the host&#x27;s build does not grow when a plugin does, plugins build in parallel, and one changing rebuilds only itself. Capabilities expand strictly opt-in: a language runtime, a store, telemetry, the call plane — each is an import the plugin chooses or a value that arrives at run time, and a plugin needing none pays for none. The smallest host binary runs just the smallest set.</p>
<p><strong>A plugin DECLARES the paths it answers; the host DISCOVERS them.</strong> A host that hand-maintains a routing row for a repository it does not build will get that row wrong, and a wrong row is an outage, not a documentation defect (§3.1 records the one that happened). The declaration is projected from the plugin&#x27;s own live router, travels as an artifact verified by the same digest as the binary, and is gated by asking the composed ROUTER where each declared path actually goes — never by consulting a committed document.</p>
<p><strong>Every app is a plugin, uniformly, and a plugin is an ordinary repository.</strong> The correspondence between apps and plugins is one-to-one and gate-enforced (§9); a plugin runs standalone as readily as it composes (§10); an optional or paid capability is a separate artifact the host loads at run time, never a build tag in public source (§11); a host enumerates its composition from the plugins&#x27; own live declarations rather than a committed catalogue (§12); each app declares its customer-facing identity as named Go fields, because a field with no Go name is silently deleted by two closed-struct round-trips on the way to the published document (§13); and a third party can fork a plugin, extend it and contribute it back using only public repositories (§14).</p>
<p><strong>Supersedes this HIP&#x27;s own earlier process model.</strong> The fused binary this document originally specified — one link that imported every subsystem as a Go package, driven by <code>cloud.Register</code> + <code>apps.Wire()</code> — is deleted. <code>cmd/cloud</code> is now a light host that links <code>zip</code>, a manifest and a console embed (402 packages) and composes ~116 per-plugin binaries as child processes. The subsystem-boundary, extension-surface, multi-language, inter-subsystem-call, single-process and migration sections that described the old model are replaced by the Specification below. Sections on Commerce&#x27;s PCI scope, the solo-vault CDE and PSP optionality are retained unchanged; they are about commerce, not about the binary, and are filed here only by history.</p>
<p><strong>This document does not restate HIP-0119.</strong> HIP-0119 is the one and only shape of a Hanzo backend service — listeners, ports, health paths, environment names, image naming, deployment. A plugin conforms to it in full and this document adds only what it does not cover. Restating it here would create the second copy HIP-0119 §10 forbids.</p>
<p><strong>Wire.</strong> Every inter-plugin call is ZAP: typed ops over a unix socket, JSON only at the system edge. No gRPC and no protobuf in Hanzo-authored code; where an external standard must be spoken at an interop boundary (OTLP, OpAMP), the conversion lives in the <code>zap</code> tooling and never in a service.</p>
<h2>Motivation</h2>
<p>Two forces, pulling the same way.</p>
<p><strong>The build.</strong> Measured 2026-07-29: <code>hanzoai/cloud</code>&#x27;s root package is 574 packages, and <code>plugin/crm</code> — whose own code is about two packages — is 576, because it imports that root to reach <code>cloud.Serve</code>. A conforming plugin built against <code>zip</code> alone is 260. The 316-package difference is not crm&#x27;s code; it is the host&#x27;s composition root, arriving as a library. Multiply by 116 plugins and that is the whole cost of the fleet&#x27;s build. It cannot be fixed inside cloud, because the coupling <em>is</em> the import.</p>
<p><strong>The repository boundary.</strong> A capability that belongs to another team, another licence, or another release cadence has to live in another repository. Today it cannot: to be mountable it must implement a <code>MountFunc</code> from cloud&#x27;s root package, so every plugin is inside cloud by construction, and the OSS/private split, per-capability release cadence and third-party extension are all blocked on the same import.</p>
<p>Both are removed by the same move: state the contract in terms of <code>zip</code>, make the plugin declare its own routing, and let the host discover instead of transcribe.</p>
<h2>Specification</h2>
<p>The key words MUST, MUST NOT, SHOULD, SHOULD NOT and MAY are to be interpreted as in RFC 2119. &quot;Plugin&quot; below means <em>a git repository whose build produces a binary a host composes at run time</em>. &quot;Host&quot; means the process that composes it — <code>hanzoai/cloud</code>&#x27;s <code>cmd/cloud</code> is the reference host, and there is nothing cloud-specific in this contract.</p>
<p><strong>This document does not restate HIP-0119.</strong> HIP-0119 is the one and only shape of a Hanzo backend <em>service</em>: two listeners, <code>/v1/</code> only, <code>/healthz</code> + <code>/readyz</code> + <code>/metrics</code> on the ops port, environment configuration, <code>&lt;org&gt;-&lt;app&gt;</code> client IDs, one CR per service, and the §9 forbidden list. A plugin binary run standalone IS a service and MUST conform to HIP-0119 unchanged. What follows is only what HIP-0119 does not say: what a plugin repository may <em>import</em>, what its <code>main</code> <em>does</em>, how it <em>declares</em> the paths it answers, what <em>projections</em> it must produce, and what <em>gates</em> prove it. Where the two touch, HIP-0119 is authoritative and this document cites it.</p>
<p>Every number below was measured on 2026-07-29 against <code>hanzoai/cloud</code> at <code>e5874218</code> and <code>github.com/zap-proto/[email protected]</code>. Re-measure before quoting one; the command is given each time.</p>
<h3>§1 The module contract</h3>
<h4>§1.1 What a plugin imports</h4>
<p>A plugin&#x27;s non-test import graph MUST contain, from first-party code, exactly:</p>
<p>| Import | Role | Status | |---|---|---| | <code>github.com/zap-proto/zip</code> | the framework: router, typed ops, transports, caller, call plane | required | | <code>github.com/zap-proto/zip/middleware</code> | <code>Recover</code>, <code>RequestID</code>, <code>Logger</code>, <code>Telemetry</code>, <code>RateLimit</code>, … | optional | | <code>github.com/hanzoai/plane</code> | the internal call contract: op-name constants and their In/Out types | only if it calls or answers a peer | | <code>github.com/hanzoai/money</code> | exact decimal amounts | only if it handles money | | one <code>zip/&lt;lang&gt;</code> adaptor | a non-Go handler runtime (§5) | only if it mounts one |</p>
<p>The third row is the one forward reference in the table. <code>github.com/hanzoai/plane</code> is the path §1.3(a) extracts the contract to, and that extraction has not landed: the module does not resolve, and the constants still live in package <code>plane</code> of the <code>hanzoai/cloud</code> module. The row names the destination anyway, because a plugin that spells the import any other way gets edited twice.</p>
<p>It MUST NOT import <code>github.com/hanzoai/cloud</code>, any <code>hanzoai/cloud/...</code> subpackage, or any other host package. That is the entire rule, and it is checked by a gate, not by review (§8.1).</p>
<p>Everything else a plugin needs — a store driver, an HTTP client, a PDF library — is the plugin&#x27;s own dependency, chosen by the plugin, paid for by the plugin, and invisible to every other plugin and to the host.</p>
<h4>§1.2 The measured floor</h4>
<p> $ go list -deps . | wc -l</p>
<p>| Binary | Packages | Of which | |---|---|---| | <code>zip</code> alone, clean module, v1.18.7 | <strong>258</strong> | 0 goja, 0 esbuild | | <code>zip</code> alone, clean module, v1.18.6 | 315 | 33 goja + esbuild | | a conforming plugin: zip + money + 2 typed ops + tenancy refusal | <strong>260</strong> | — | | <code>cmd/cloud</code> (the host, zero app imports) | 402 | — | | <code>hanzoai/cloud</code> root package | 574 | still imports 10 <code>apps/*</code> packages | | <code>plugin/crm</code> (today&#x27;s shape — imports <code>cloud</code>) | <strong>576</strong> | its own code is ~2 packages | | <code>hanzoai/cloud/plane</code> (already a leaf) | 74 | stdlib + <code>hanzoai/money</code> |</p>
<p>The 316-package difference between a conforming plugin (260) and today&#x27;s <code>plugin/crm</code> (576) is the whole of what §1.3 removes. <code>zip</code> v1.18.7 cutting <code>zip/runtime</code> out of the root package is what makes 258 the floor rather than 315; a plugin MUST require <code>zip &gt;= v1.18.7</code> so that a JavaScript interpreter and a bundler are not linked into a binary that has no JavaScript.</p>
<h4>§1.3 The six gaps, and where each one goes</h4>
<p><code>plane/</code> is the model. It is a LEAF: op-name constants plus the In/Out types those ops carry, importing nothing of the host&#x27;s, which is precisely what lets an aggregator call the ledger without linking it. Every gap below is resolved by one of three placements, in this order of preference:</p>
<ol><li><strong>In <code>zip</code></strong> — when it is a property of <em>any</em> typed op on <em>any</em> transport.</li><li><strong>In one tiny published contract module</strong> — when it is a name both ends must</li></ol>
<p> spell identically and neither owns.</p>
<ol><li><strong>At run time</strong> — when it is a credential, a key, a sink or a policy. A value</li></ol>
<p> that arrives at run time cannot be a compile-time dependency, and a plugin that receives it holds no code to keep in sync.</p>
<p>Nothing is resolved by a fourth placement. In particular nothing is resolved by a build tag, and nothing is resolved by a stub: where a capability may be absent, the constructor MUST exist either way and MUST be nil-safe, so no caller ever branches on availability (<code>middleware.Telemetry(nil)</code> returning a pass-through handler is the shape).</p>
<p><strong>(a) The plane contract — a contract module, and one function in zip.</strong></p>
<p><code>github.com/hanzoai/plane</code> is <code>hanzoai/cloud/plane</code> extracted verbatim to its own module: 74 packages, no host imports, already correct. The extraction is a module-path change and nothing else — and it is the part still to be done. There is no <code>hanzoai/plane</code> module to fetch yet; the package is one directory of <code>hanzoai/cloud</code> until the move lands.</p>
<p>The <em>client and server halves</em> are already zip and MUST NOT be duplicated. Every helper the host currently wraps them in is deleted in the change that names its survivor:</p>
<p>| Deleted | Survivor | |---|---| | <code>cloud.Plane()</code> | <code>zip.New(zip.Config{AppName: name})</code> — a second app, listening only on <code>zip.SocketPath(name)</code>, never mounted on the edge | | <code>cloud.ServePlane(name, log)</code> | <code>app.Listen(zip.SocketPath(name))</code> | | <code>cloud.Peer(app)</code> | <code>zip.DialApp(name)</code> | | <code>cloud.Who(ctx)</code> | <code>zip.CallerOf(ctx)</code> | | <code>cloud.For(ctx, org)</code> | <code>zip.WithCaller(ctx, zip.Caller{Org: org})</code> | | <code>cloud.As(c, org)</code> | <code>zip.Delegate(c *Ctx, org string) context.Context</code> — MOVE to zip; it reads only <code>Ctx</code> accessors | | <code>cloud.bindRuntimeDir</code> | the host sets <code>ZIP_RUNTIME_DIR</code> on its children; <code>zip.RuntimeDir()</code> already resolves <code>$ZIP_RUNTIME_DIR</code> → <code>$XDG_RUNTIME_DIR/zip</code> → <code>/run/zip</code> | | <code>cloud.Ask[In,Out]</code> | <code>zip.Ask<a href="ctx, name, op, in">In,Out</a></code> — ADD to zip: dial, call, close |</p>
<p><code>zip.Ask</code> is the only genuinely missing piece. <code>zip</code> has <code>DialApp</code> and <code>Call</code>; it does not have the one-shot, so every caller writes the same six lines. One function, in zip, because &quot;dial a peer by name and invoke one op&quot; is a property of the call plane and not of any deployment.</p>
<p><strong>(b) Identity and the tenant read — in zip, and the naive rule is WRONG.</strong></p>
<p><code>zip.CallerOf(ctx).Org != &quot;&quot;</code> is NOT a sufficient tenancy check, and the host&#x27;s own code already knows why. <code>apps/principal.OrgOf</code> refuses on three conditions, not one:</p>
<pre><code class="lang-go">func OrgOf(user, org string) (string, bool) {
if strings.TrimSpace(user) == &quot;&quot; { return &quot;&quot;, false } // no validated principal
org = strings.TrimSpace(org)
if org == &quot;&quot; || len(org) &gt; MaxOrgLen { return &quot;&quot;, false }
return strings.Clone(org), true
}</code></pre>
<p><code>X-Org-Id</code> on its own is a client-settable header. Without the validated <code>user</code> claim beside it, &quot;the org is non-empty&quot; is a statement the caller made about itself. And an unbounded org is retained past the request as a store key and a ledger key, so a length bound is not hygiene.</p>
<p>So <code>zip</code> MUST carry that decision, once, as</p>
<pre><code class="lang-go">// Tenant is the tenant a call may act for, or (&quot;&quot;, false).
func Tenant(ctx context.Context) (string, bool)</code></pre>
<p>reading <code>CallerOf(ctx)</code> and applying exactly <code>OrgOf</code>&#x27;s rule. <code>apps/principal</code>&#x27;s copy is deleted in the same change. A plugin MUST use <code>zip.Tenant</code> and MUST refuse on <code>!ok</code>; a plugin MUST NOT re-derive the rule.</p>
<p>Where the principal COMES FROM is HIP-0134 and is not restated here: IAM establishes it once, nothing re-derives it, and a call carries it as delegation rather than assertion because the socket already bounds who may speak. Two obligations follow for the parties this contract does cover:</p>
<ul><li><strong>The host</strong> MUST delete every header in <code>zip</code>&#x27;s <code>identityHeaders</code> set from an</li></ul>
<p> inbound external request before proxying it to a child, and attach the principal IAM established. Deleting a forgery is not minting an identity, and a host that skips it hands a client&#x27;s own <code>X-Org-Id</code> straight to a plugin.</p>
<ul><li><strong>The plugin</strong> MUST NOT validate a token and MUST NOT re-derive a principal. It</li></ul>
<p> reads the one that arrived, checks it is PRESENT and well-formed with <code>zip.Tenant</code>, and then authorizes — its own rules, in its own process, on the decoded input, which is what HIP-0134 §3 keeps in the plugin and what process isolation actually buys. 116 JWKS clients would be 116 places to get an issuer wrong, and cloud&#x27;s current per-child validator (<code>cloud.SanitizeIdentity</code>) is a host package no external repo can import.</p>
<p>Checking that a delegated principal is present and bounded is not a second implementation of IAM. It is the precondition for using the value as a store key, and skipping it is how an empty string becomes a tenant.</p>
<p><strong>(c) A store — at run time.</strong></p>
<p>The plugin chooses its own store library and pays for it. The <em>key</em> arrives at run time: the plugin asks the KMS peer for its data-plane key over the plane (<code>plane.KMSGet</code>), and the launch token it presents is an environment variable the host stamped on that one child. Both the token&#x27;s variable name and the broker exchange are op-name constants in <code>hanzoai/plane</code>; no credential library is imported. A plugin that cannot obtain a key MUST fail closed at its first store open and MUST NOT write plaintext.</p>
<p><strong>(d) Config — nothing is missing.</strong></p>
<p>HIP-0119 §5 already names the shared environment (<code>PORT</code>, <code>OPS_PORT</code>, <code>LOG_LEVEL</code>, <code>BRAND</code>, <code>DOMAIN</code>); <code>zip</code> names <code>ZIP_ADDR</code> and <code>ZIP_RUNTIME_DIR</code>. A plugin reads its own variables with <code>os.Getenv</code> under a <code>&lt;NAME&gt;_</code> prefix and MUST start with zero required flags. There is no config package to import and none is to be written: a shared config struct is how ~100 host variables became a dependency of every subsystem.</p>
<p><strong>(e) Telemetry — at run time, through a nil-safe seam that already exists.</strong></p>
<p><code>middleware.Telemetry(sink O11ySink)</code> is the seam, and <code>Telemetry(nil)</code> is a pass-through. A plugin MUST install it and MUST NOT link an OTLP SDK: the collector lives in the o11y binary alone, and spans leave a plugin as ordinary plane calls to o11y&#x27;s op. This is the direction the OTLZ work is taking fleet-wide; a plugin that links OTLP today adds 43 packages to its floor for a capability the host already provides.</p>
<p><strong>(f) The host&#x27;s own facilities — not available, by construction.</strong></p>
<p>A plugin does not serve the console, does not thread operator flags, does not scope credentials for other processes, and does not own the ops listener when it runs as a child (<code>zip.Addr(&quot;&quot;) != &quot;&quot;</code> means a host handed it a socket; the ops port is the host&#x27;s — HIP-0119 §1 applies to the <em>deployment&#x27;s</em> listeners, and a child&#x27;s socket is not one). These are edge concerns and stay in one process.</p>
<h3>§2 The entry point</h3>
<p>A plugin <code>main</code> does four things, in this order: construct, register, describe if asked, serve. This is the generalisation of what works today — <code>plugin/o11y/main.go</code> is the only existing main written against <code>zip</code> alone, and the other 115 are <code>cloud.Serve</code> calls, which is exactly the import this contract removes.</p>
<pre><code class="lang-go">// Command billing is the billing service. It builds as its own binary; a host
// composes it at run time.
package main
//go:generate go run github.com/zap-proto/zip/cmd/zipdoc
import (
&quot;fmt&quot;
&quot;os&quot;
&quot;github.com/zap-proto/zip&quot;
&quot;github.com/zap-proto/zip/middleware&quot;
)
const name = &quot;billing&quot;
func main() {
if err := run(); err != nil {
fmt.Fprintf(os.Stderr, &quot;%s: %v\n&quot;, name, err)
os.Exit(1)
}
}
func run() error {
app := zip.New(zip.Config{AppName: name})
app.Use(middleware.Recover(), middleware.RequestID(), middleware.Logger(app.Logger()))
svc := newService() // this plugin&#x27;s own dependencies, built here
svc.ops(app) // typed ops — the ONE registry (§4)
svc.plane(planeApp(name)) // peer ops, on the second app (§1.3a)
// Describe instead of serve. Before anything opens a store: a projection is
// a function of the code, and a describe run must not touch a real store.
if mode, dest, ok := zip.Described(); ok {
return zip.Describe(app, mode, dest)
}
// zip.Addr: the socket a host handed us, or our own port run directly.
// This is the whole plugin side of the transport contract.
return app.Listen(zip.Addr(&quot;:9653&quot;))
}</code></pre>
<p>Requirements:</p>
<ol><li><code>zip.Config.AppName</code> MUST equal the plugin&#x27;s name, and the name MUST be the</li></ol>
<p> binary&#x27;s name, the socket&#x27;s stem (<code>zip.SocketPath(name)</code>), the <code>Declaration.Name</code> (§3) and the <code>&lt;org&gt;-&lt;app&gt;</code> IAM app segment. One name, no mapping table.</p>
<ol><li>The last line MUST be <code>app.Listen(zip.Addr(fallback))</code>. Reading <code>ZIP_ADDR</code></li></ol>
<p> any other way, or binding a fixed port when a host handed one over, is the failure where every child but the first dies on &quot;address already in use&quot;.</p>
<ol><li>Peer ops MUST be registered on a SECOND <code>*zip.App</code> that listens only on</li></ol>
<p> <code>zip.SocketPath(name)</code>. A typed op rides every transport its app listens on, so an internal op registered on the edge-facing app is an internal op served on <code>:8000</code>. The separation is structural, not a check.</p>
<ol><li><code>main</code> MUST NOT read configuration, open a store, or dial a peer before the</li></ol>
<p> describe check.</p>
<ol><li><code>zip.Config.Eager</code> MUST be set true if and only if the plugin&#x27;s work is not</li></ol>
<p> request-driven — it owns a listener, a consumer or a background loop. This is the one fact about a plugin that its router cannot show (§3.2).</p>
<p><code>zip.Described()</code> and <code>zip.Describe(app, mode, dest)</code> replace the host&#x27;s <code>cloud.SpecRequested</code> / <code>cloud.WriteSpec</code> pair and are the only new API §2 requires. <code>mode</code> is <code>openapi</code> or <code>declare</code> (§3, §4). Both MUST write to a <strong>file</strong>, never stdout: a plugin&#x27;s own dependencies write to stdout at construction — <code>zip.New</code> itself logs a line, GORM logs queries, sqlite-vec prints a warning — and <code>&gt; file</code> splices those into the front of the document.</p>
<h3>§3 The declaration — the manifest problem, inverted</h3>
<h4>§3.1 Why a host-authored row cannot survive another repo</h4>
<p><code>manifest.Apps</code> in <code>hanzoai/cloud</code> is a hand-authored table of <code>{Name, Prefixes, Eager}</code> and it <strong>is the router</strong>: <code>cmd/cloud</code> mounts each row&#x27;s prefixes through <code>zip.Load</code> and the first match wins. A prefix nobody wrote down is not a documentation gap; it is a 404 or a 405 on live traffic.</p>
<p>The proof is on the record. The <code>analytics</code> row listed the read endpoints and omitted the four ingestion endpoints <code>apps/analytics/event.go</code> actually serves (<code>/v1/event</code>, <code>/v1/insights/e</code>, <code>/v1/analytics</code>, <code>/v1/analytics/batch</code>). Every product beacon in the fleet therefore fell past every prefix onto the row holding the bare <code>/v1</code> remainder, which does not serve them, and answered 405 — starting eighteen seconds after the ReplicaSet running the first image in which <code>manifest.Apps</code> <em>was</em> the router. The row had been harmless for as long as each app called its own <code>routes()</code>; the mega-build&#x27;s death made it load-bearing, and a list that had been documentation became a routing table overnight.</p>
<p>A cross-repo plugin makes that failure permanent rather than occasional. Cloud cannot hand-maintain a prefix row for a repository it does not build: the row and the routes are then edited by different people, in different repos, on different schedules, with no compiler and no test between them.</p>
<p>So the direction MUST invert. <strong>The plugin declares; the host discovers.</strong></p>
<h4>§3.2 What the binary emits</h4>
<p>The binary already describes itself — it emits its own OpenAPI subset from its own live router. It can therefore describe its <em>routing</em> the same way, from the same source. <code>zip</code> gains one type and one method:</p>
<pre><code class="lang-go">// Declaration is what a plugin tells a host: who it is, whether it must be
// running before the first request arrives, every route pattern its router
// holds, and every op name it answers on the call plane.
type Declaration struct {
Name string `json:&quot;name&quot;`
Eager bool `json:&quot;eager,omitempty&quot;`
Routes []Route `json:&quot;routes&quot;`
Ops []string `json:&quot;ops,omitempty&quot;`
}
// Route is one pattern in the ROUTER&#x27;s own spelling — &quot;:id&quot;, not &quot;{id}&quot;.
type Route struct {
Method string `json:&quot;method&quot;`
Pattern string `json:&quot;pattern&quot;`
}
// Declaration projects the live router. Nothing is inferred from the AST, from
// a golden, or from the OpenAPI document.
func (a *App) Declaration() Declaration</code></pre>
<p>Rules:</p>
<ol><li><code>Routes</code> MUST come from the router (<code>a.Fiber().GetRoutes(true)</code>), sorted by</li></ol>
<p> <code>(pattern, method)</code>, deduplicated. It is therefore complete by construction: a route the plugin serves and does not publish is still declared, which is precisely the analytics-ingestion case.</p>
<ol><li><code>Routes</code> MUST exclude <code>/.well-known/*</code>. Those are zip&#x27;s own control plane,</li></ol>
<p> per process; the host serves its own.</p>
<ol><li><code>Ops</code> MUST be every registered <code>OperationID</code>. The op token is the operation&#x27;s</li></ol>
<p> one identity: the OpenAPI <code>operationId</code>, the MCP tool name, the CLI command and the plane op are the same string (§4).</p>
<ol><li><code>Eager</code> is <code>Config.Eager</code>. It is the only field not derived from the router.</li><li>There is no <code>Prefixes</code> field and no <code>Remainder</code> flag. A plugin that owns a</li></ol>
<p> version remainder declares the catch-all route it actually registered (<code>/v1/*</code>); the host&#x27;s rule about remainders reads the routes, so the fact lives in one place.</p>
<p>This is implementable today with no change to zip beyond exporting it. Measured:</p>
<p> $ ./demo-plugin declare {&quot;name&quot;:&quot;demo&quot;,&quot;routes&quot;:[ {&quot;method&quot;:&quot;POST&quot;,&quot;pattern&quot;:&quot;/v1/demo/quote&quot;}, {&quot;method&quot;:&quot;GET&quot;,&quot;pattern&quot;:&quot;/v1/demo/quotes/:id&quot;}]}</p>
<h4>§3.3 How the declaration travels</h4>
<p>A host mounts a plugin&#x27;s routes <strong>before</strong> starting it — that is what makes lazy composition possible — so the host MUST NOT have to execute the plugin to learn its routes. The declaration therefore travels as a verified artifact beside the binary:</p>
<ul><li><code>hanzoai/ci</code> runs <code>&lt;binary&gt; declare &lt;name&gt;.plugin.json</code> in the same job that</li></ul>
<p> built the binary, and publishes it beside the binary with its own SHA-256 in <code>binaries.json</code>. The declaration is a function of the bits by construction: same job, same binary, no second source.</p>
<ul><li>A host that ships plugins in its image writes <code>&lt;name&gt;.plugin.json</code> next to</li></ul>
<p> <code>&lt;name&gt;</code> at image-build time, from the same rule.</p>
<ul><li>A host that installs a plugin from a release reads the declaration from the</li></ul>
<p> verified index and MUST refuse a plugin whose declaration digest does not verify, exactly as it refuses an unverified binary.</p>
<p>A host repository MAY commit the declarations it composed — cloud does, as it commits <code>plugin/&lt;app&gt;/openapi.json</code> — but only because a gate CI actually runs regenerates them from source and fails on any diff (§8.4). A committed artifact that nothing forces back to source is a golden, and §3.5 exists because a golden was consulted instead of a router.</p>
<p>Updating a plugin is then ONE commit in the host repo that moves <code>{URL, Sum, declaration}</code> together, and the routing change is <em>visible in the diff</em>: the six analytics endpoints appear or disappear as lines, reviewed, instead of being absent from a table nobody diffed against reality.</p>
<h4>§3.4 How the host validates a declaration it did not write</h4>
<p>The host MUST reject a declaration that fails any of:</p>
<ol><li><strong>Digest.</strong> The declaration verifies against the digest in the index that also</li></ol>
<p> authorized the binary.</p>
<ol><li><strong>Shape.</strong> Every <code>Pattern</code> is absolute, contains no <code>..</code>, and begins with a</li></ol>
<p> literal segment. A pattern beginning with a parameter (<code>/:org/:repo</code>) matches every request of that arity in the fleet; in one binary its handler could inspect the Host and fall through, but a request proxied to a child never falls through.</p>
<ol><li><strong>Namespace.</strong> Every <code>Pattern</code> is under <code>/v1/</code> (HIP-0119 §2), or under a root</li></ol>
<p> the host reserves and lists by name (<code>/login/oauth</code>, <code>/.well-known/...</code>, <code>/healthz</code>). No <code>/api/</code>. No <code>/v2</code>.</p>
<ol><li><strong>Remainder.</strong> At most one plugin in the composition declares a</li></ol>
<p> version-remainder catch-all (<code>/v1/<em></code>), and which plugin that is MUST be host configuration rather than a first-come-first-served race. A bare version root claims paths other plugins own </em>and paths that do not exist yet*.</p>
<ol><li><strong>Name.</strong> <code>Declaration.Name</code> equals the name the host installed it under, and</li></ol>
<p> is unique in the composition.</p>
<ol><li><strong>Liveness agreement.</strong> On a child&#x27;s first start, the host reads the child&#x27;s</li></ol>
<p> live declaration from <code>/.well-known/zip/plugin.json</code> and compares it to the one it routed. A mismatch means the mounted routes are not the served routes; the host MUST log it by name and MUST leave that plugin&#x27;s prefixes answering 503 rather than 404-ing them forever, and MUST keep serving every other plugin. That is the same degrade-not-abort policy a failed start already gets: being first in a list is not a claim on everyone else&#x27;s availability.</p>
<h4>§3.5 The gate: the ROUTER ORACLE over the union, at build time</h4>
<p><code>zip.Load</code> accepts a duplicate claim <strong>silently</strong> — measured: a second <code>Load</code> of <code>/v1/x</code> by a different plugin returns <code>nil</code> and the first registration keeps answering. So the conflict gate is the host&#x27;s, and it MUST run at build time.</p>
<p>There is exactly one gate, and it asks the ROUTER:</p>
<pre><code class="lang-go">// For every route every plugin declared, compose the fleet&#x27;s real router
// through the real zip.Load, send a concrete request, and require the answer to
// be the plugin that declared it.
func TestEveryDeclaredRouteReachesItsPlugin(t *testing.T) { … }</code></pre>
<ul><li>The transport is an oracle: a mounted plugin is whatever answers at its</li></ul>
<p> address, so an address that answers with its own NAME turns &quot;where does this request go&quot; into a value the test reads. Only the WIRE is replaced. <code>Load</code>, <code>Mount</code>, the patterns and the first-match are the fleet&#x27;s own.</p>
<ul><li>Parameters are substituted with a value no route spells literally, so a</li></ul>
<p> substitution can never land on a sibling&#x27;s static segment and report the wrong owner.</p>
<ul><li>The gate MUST refuse a vacuous run: `if probed == 0 { t.Fatal(&quot;this gate</li></ul>
<p> proved nothing&quot;) }`. Every way it could examine zero routes — an empty composition, declarations that decoded to nothing — is a defect elsewhere that would otherwise arrive as a green tick.</p>
<ul><li>Known defects are a LEDGER that may only SHRINK. A new entry fails; a stale</li></ul>
<p> entry fails just as loudly, because a fix nobody records is a fix nobody can see, and a ledger padded with fixed entries hides the next real one behind a number nobody trusts.</p>
<ul><li>The gate MUST NOT exempt a route because it appears in any document.</li></ul>
<p> <code>openapi/weave_test.go</code> looked for this exact defect and could not find it: it exempted any path already present in <code>openapi.yaml</code> — the artifact it was protecting — and reported survivors with <code>t.Logf</code>. So it printed nothing and passed while the fleet misrouted 58 published paths. <strong>One side of a comparison has to be SOURCE.</strong> Here both sides are: the declaration is projected from the plugin&#x27;s router, and the destination is read from the composed router.</p>
<p><code>zip.Load</code> SHOULD additionally return an error when a second plugin claims a pattern already claimed. That catches exact duplicates at compose time with a clear message; it cannot catch shadowing (a parameter sibling swallowing another plugin&#x27;s static path is sometimes legitimate and sometimes an outage), which is why the oracle remains the gate. Two checks, two failures, not two ways to do one thing.</p>
<p><strong>Order stops mattering.</strong> Measured: with exact declared patterns, mounting a parameter sibling (<code>/v1/demo/quotes/:id</code>, plugin A) before a deeper static sibling (<code>/v1/demo/quotes/special</code>, plugin B) routes each to its owner, and so does the reverse order — the router&#x27;s specificity decides, not the mount sequence. <code>manifest/order_test.go</code>&#x27;s frozen order exists because prefixes were widened ancestors; with declarations it is deleted. Cross-repo composition cannot depend on a total order that no single repo owns.</p>
<h4>§3.6 What a declaration cannot express</h4>
<p>A capability that must run as MIDDLEWARE on another plugin&#x27;s router is not a plugin. <code>apps/zen</code> inspects every <code>/v1</code> request, claims the ones whose model is a zen SKU and calls <code>Next()</code> for the rest; it dispatches on a BODY field, so it can enumerate no paths, and a proxied request never falls through to a next candidate. Such a capability MUST be part of the binary whose router it filters, or MUST become a route that binary forwards to. It MUST NOT be given a declaration, and the <code>bareVersionExempt</code> set that currently carries it is deleted with the prefix table.</p>
<h3>§4 The projections — one registry, four documents</h3>
<p>A typed op is ONE registry entry:</p>
<pre><code class="lang-go">zip.Post(app, &quot;/v1/billing/invoices&quot;, o.create, zip.WithOperationID(&quot;billing_invoice_create&quot;))</code></pre>
<p>and it MUST produce all four projections, from that one entry:</p>
<p>| Projection | Producer | Consumer | |---|---|---| | OpenAPI subset | <code>app.OpenAPISpec()</code> → <code>&lt;binary&gt; openapi &lt;file&gt;</code> | the woven fleet spec, every generated SDK | | MCP tool | <code>app.MCPTools()</code> | agents | | CLI command | <code>zip.CommandsFromSpec(spec)</code> | <code>hanzo &lt;service&gt; &lt;command&gt;</code> | | Plane op | the <code>OperationID</code> | peers, via <code>zip.Ask</code> |</p>
<p>The <code>OperationID</code> is the same string in all four. An untyped route (<code>app.Get(path, handler)</code>) is a route and NOTHING else: no schema, no tool, no command, no op. Measured in <code>hanzoai/cloud</code>: 414 typed op registrations against 725 untyped route registrations, and 1,427 operations across 1,011 paths in the woven spec — so the majority of the published surface is invisible to three of the four projections. A plugin MUST register every op typed. <code>zip.Ctx</code> handlers are permitted only where the response cannot be a value: a redirect, a stream, a non-JSON body, a second legitimate success code.</p>
<h4>§4.1 <code>//go:generate zipdoc</code> is not optional</h4>
<p>Go drops doc comments at compile time. Reflection sees types and struct tags, never comments. So a build-time AST pass is the ONLY way an op&#x27;s prose reaches a document, and a package without the directive can NEVER get prose into the spec, however correct everything else is.</p>
<p>Every package registering a typed op MUST carry, verbatim:</p>
<pre><code class="lang-go">//go:generate go run github.com/zap-proto/zip/cmd/zipdoc</code></pre>
<p>and MUST commit the resulting <code>zipdoc_gen.go</code> (a bare <code>go build</code> does not run generate, so an untracked file is a binary whose document has no descriptions). <code>make test</code> MUST run <code>zipdoc -check</code> so a lift that drifts from its source turns CI red instead of shipping stale prose.</p>
<p><strong>The doc comment is a product surface, not a comment.</strong> Measured on a two-op plugin, before and after adding the directive:</p>
<p> before: MCP tool demo_quote description &#x27;&#x27; OpenAPI description None after: MCP tool demo_quote description &#x27;quote prices one reference.&#x27; OpenAPI POST /v1/demo/quote description &#x27;quote prices one reference.&#x27;</p>
<p>The same sentence reaches the published API document a customer reads and the tool description an agent reads <em>when choosing whether to call it</em>. <code>Example:</code> and <code>Response:</code> lines in the comment become the spec&#x27;s examples, because a spec nobody can try is most of an interactive document wasted.</p>
<p>Measured gap in <code>hanzoai/cloud</code>: six packages register typed ops and carry no directive — <code>apps/admin/core</code>, <code>apps/commerce</code>, <code>apps/iam</code>, <code>apps/kms</code>, <code>apps/platform</code>, <code>apps/treasury</code>. Two of them are plane surfaces. Their ops carry <code>WithSummary(&quot;…&quot;)</code> strings sitting directly under a doc comment that says the same thing: two places to change, one to forget. §8.5 turns that into a failure.</p>
<h4>§4.2 Composition, never carving</h4>
<p>A plugin&#x27;s OpenAPI subset MUST be generated from the plugin&#x27;s OWN live router. It MUST NOT be sliced out of a fleet document by prefix — that makes the fleet the source and the plugin a derivative, which is backwards, and is exactly how a catch-all silently swallows a neighbour&#x27;s routes. The fleet document is woven upward from the subsets, refusing when two plugins claim one path+method or mean different things by one schema name.</p>
<p><code>plugin/ingress</code> lost eight paths from every published SDK in every language because the only gate compared two DERIVED artifacts, which agreed with each other while both were wrong.</p>
<h3>§5 Language runtimes — opt-in adaptors, in zip</h3>
<p>Go is native and built in. Every other language is an ADAPTOR, each in its own package inside the <code>zip</code> module, each owning its own dependencies. A plugin that needs none pays for none.</p>
<p>| Package | Engine | Sandbox | Status | |---|---|---|---| | <code>zip/js</code> | goja + esbuild | soft | exists as <code>zip/runtime</code>; RENAME | | <code>zip/wasm</code> | wazero | hard | MOVE from <code>hanzoai/base/plugins/wasmvm</code> | | <code>zip/py</code> | CPython sub-interpreters | none — single tenant only | MOVE from <code>base/plugins/pyvm</code> | | <code>zip/star</code> | starlark | hard, deterministic, no I/O | MOVE from <code>base/plugins</code> | | <code>zip/v8</code> | v8go (cgo) | soft | add only when a consumer asks |</p>
<p>The seam is already right and MUST NOT be duplicated: <code>zip.Loader</code> and <code>zip.Module</code> are interfaces declared in root <code>zip</code>, which imports no implementation. A plugin declares the runtime it needs by <strong>importing that adaptor and passing its loader</strong>:</p>
<pre><code class="lang-go">import &quot;github.com/zap-proto/zip/js&quot;
app := zip.New(zip.Config{AppName: &quot;webhooks&quot;, Loader: js.Loader()})
app.Module(&quot;POST /v1/webhook/transform&quot;, &quot;goja&quot;, &quot;./ext/transform&quot;)</code></pre>
<p>The import IS the declaration. There is no runtime flag, no manifest field and no build tag, and Go&#x27;s module graph pruning makes it free: measured, <code>zip</code>&#x27;s <code>go.mod</code> still requires goja and esbuild for <code>zip/js</code>, and a plugin that does not import <code>zip/js</code> builds 258 packages with zero goja packages in its graph. One repo, N opt-in packages, each cost borne only by the binary that asks.</p>
<p><code>hanzoai/base</code> MUST reuse these adaptors and delete <code>base/plugins/{extruntime,gojavm,wasmvm,v8vm}</code>. Base is an application; mounting a foreign-language handler is a framework concern, and today a plugin that wants one route in JavaScript must depend on a whole application framework to get it. <code>app.Module</code> stays the ONE mount verb — there is no <code>ModuleWasm</code>, <code>ModuleGoja</code> or <code>ModulePython</code>, on purpose.</p>
<p>A module route registers a route and no op, so it is in no document, is no MCP tool and is reachable by no peer. That hole closes when an extension DECLARES its contract in its manifest and <code>zip.Module</code> surfaces the schema; until then a route whose contract IS known belongs in a typed op with the module as an implementation detail behind it.</p>
<h3>§6 Identity and tenancy — non-negotiable</h3>
<ol><li>A plugin MUST NOT read a tenant from caller-supplied input. There MUST be no</li></ol>
<p> <code>Org</code> field in any <code>In</code> type, on any op, on any transport. An org in the argument is an org the caller chose, and a caller that can name the org can bill or read another tenant.</p>
<ol><li>The tenant rides the CALLER: forwarded from the gateway&#x27;s assertion with</li></ol>
<p> <code>zip.Ctx.Forward</code> (a typed handler&#x27;s ctx already carries it), or stated once and explicitly by a background job with <code>zip.WithCaller</code>. An inbound request always wins over a stated caller, so a background job can supply an identity where there is none and can never launder one.</p>
<ol><li>The callee reads <code>zip.Tenant(ctx)</code> and MUST refuse <code>!ok</code> — which is stricter</li></ol>
<p> than &quot;refuse empty&quot; for the reason in §1.3(b): a non-empty <code>X-Org-Id</code> with no validated user claim beside it is a client&#x27;s own assertion. Establishing the principal is IAM&#x27;s (HIP-0134); checking that one arrived and is bounded before using it as a key is the callee&#x27;s.</p>
<ol><li><code>Caller.Admin</code>, <code>Caller.OrgAdmin</code> and <code>Caller.Owner</code> are three distinct</li></ol>
<p> authorities and reading one for another is a privilege escalation. <code>OrgAdmin</code> says a person administers THEIR OWN org; <code>Owner</code> says which org that is; a deployment reserving one org for platform operators gates cross-tenant surfaces on <code>Owner</code> alone.</p>
<ol><li>An org is used VERBATIM — trimmed, never lower-cased, never truncated.</li></ol>
<p> Folding collapses distinct owners (&quot;acme&quot;, &quot;ACME&quot;, a 32-char prefix) into one bucket, which is itself a cross-tenant break.</p>
<ol><li>Money is an exact decimal with its currency beside it (<code>plane.Money</code>), never a</li></ol>
<p> count of minor units. HUSD carries 18 decimals, so &quot;cents&quot; is not the smallest unit; a per-token charge is routinely finer than one. A malformed amount is an ERROR, never a zero — a gate that read an unparseable charge as &quot;nothing to authorize&quot; would let the work through free.</p>
<ol><li>The wire is ZAP. <code>json</code> tags are the DOCUMENT&#x27;s vocabulary only. A field IS</li></ol>
<p> its offset, so compatibility is STRUCTURAL: <strong>append fields at the end, and only at the end.</strong> Reordering, inserting or retyping one changes what every existing peer reads.</p>
<ol><li>A peer socket is <code>0600</code> and SO_PEERCRED-authenticated, so a caller on it is</li></ol>
<p> one of our own processes; <code>zip.PeerOf(ctx)</code> is available as a coarse infrastructure gate under the per-user authorization. That is not a trust boundary between our own plugins, and a check that pretends otherwise should say what it is.</p>
<h3>§7 CI and release</h3>
<p>A plugin repo carries exactly two CI files and no build logic of its own.</p>
<p><code>hanzo.yml</code> at the root:</p>
<pre><code class="lang-yaml">binaries:
- name: billing
main: .
platforms: [linux/amd64, linux/arm64]
test:
- name: go-test
run: |
set -e
export GOPRIVATE=&#x27;github.com/hanzoai/*&#x27; GOWORK=off
make test</code></pre>
<p><code>.hanzo/workflows/cicd.yml</code>, unchanged from repo to repo — a repository keeps ONE workflow directory and this is the fleet&#x27;s, while the <code>uses:</code> line references the reusable workflow by path at a pinned tag, which is resolved rather than scanned (HIP-0036 §1, §2):</p>
<pre><code class="lang-yaml">name: CI/CD
on:
push: { branches: [main], tags: [&quot;v*&quot;] }
pull_request:
workflow_dispatch:
jobs:
cicd:
uses: hanzoai/ci/.github/workflows/build.yml@v2
secrets: inherit</code></pre>
<ul><li>Images push to <strong><code>oci.hanzo.ai</code></strong>, org-namespaced <code>&lt;host&gt;/&lt;org&gt;/&lt;app&gt;</code>.</li></ul>
<p> Registries never mix. <code>ghcr.io/&lt;org&gt;</code> remains only for already-published OSS deps external users pull.</p>
<ul><li>The only stored secret is the machine identity the build authenticates to KMS</li></ul>
<p> with, set on the forge, since <code>.hanzo/workflows/</code> is what the forge reads. Registry and IAM credentials come from KMS at run time; the build holds no cluster credential at all, because it does not deploy (HIP-0036 §Deployment).</p>
<ul><li>Binaries build on every push (an arm64 cross-compile that breaks fails the PR</li></ul>
<p> that broke it) and publish on a tag, after the <code>test:</code> gate. <code>binaries.json</code> ships beside them with <code>{name, os, arch, url, sha256}</code> for every artifact, plus each artifact&#x27;s <code>&lt;name&gt;.plugin.json</code> declaration (§3.3).</p>
<ul><li>Builds are <code>CGO_ENABLED=0 -trimpath</code>: the digest must be a function of the</li></ul>
<p> source, not of the checkout path.</p>
<h4>§7.1 A tag is a RECEIPT</h4>
<p>In <code>hanzoai/cloud</code> a <code>v*</code> tag is minted only AFTER build + smoke + image push succeed: <code>main push → compute version → build → smoke → push image → tag → notify</code>. Any failure fails BEFORE the tag and leaves no receipt. The inverted, tag-triggers-build order left phantom tags with no image behind them, which is <code>ImagePullBackOff</code> on a version that never existed. <strong>Hand-tagging forges a receipt for an image that was never built.</strong></p>
<p>The equivalent rule for a plugin repo:</p>
<blockquote><p>**A <code>v*</code> tag on a plugin repo asserts: this commit&#x27;s <code>test:</code> gate passed, its binaries built for every declared platform, its declaration was projected from those exact binaries, and all of it was published with digests. A tag MUST be minted by the pipeline that proved those things, never by a person and never before them.**</p></blockquote>
<p>Concretely: the release job publishes artifacts + <code>binaries.json</code> + declarations, and only then creates the tag. A host installs unattended by digest, so a tag that does not correspond to published, verified bits is a supply-chain lie — and it is a worse lie for a plugin than for an image, because the host will <em>execute</em> the bits the tag pointed at.</p>
<p>Patch bumps only, from the actual latest tag +1, and never above <code>v1.x.x</code>.</p>
<h3>§8 The gates a conforming repo MUST run</h3>
<p>Each gate names the failure it catches. All of them run from <code>make test</code>, and <code>hanzo.yml</code>&#x27;s <code>test:</code> block MUST invoke <code>make test</code> — not a bare <code>go test</code>.</p>
<p><strong>§8.1 <code>plugin-is-a-leaf</code>.</strong> <code>go list -deps ./... | grep -E &#x27;^github.com/hanzoai/(cloud|base)($|/)&#x27;</code> MUST be empty. <em>Catches:</em> one stray import of a host package dragging 316 packages back into the plugin, whose only symptom is a slow build. A grep over source is NOT this gate: the dangerous break is the one that still compiles, so the check is over the import graph a build actually produces.</p>
<p><strong>§8.2 <code>builds-and-mounts-alone</code>.</strong> The binary links and, run with no host, mounts its whole surface and reaches <code>listening</code>. <em>Catches:</em> a plugin that only works because something else in a fused binary initialised it first.</p>
<p><strong>§8.3 <code>declaration-current</code>.</strong> Regenerate <code>&lt;name&gt;.plugin.json</code> from the built binary; fail on any diff. Additionally assert <code>openapi ⊆ declaration</code>: every path in the OpenAPI subset MUST appear in the declaration. <em>Catches:</em> the analytics-ingestion outage class — a published path the host will not route. The subset relation is one-way: a served-but-unpublished route (a webhook endpoint) MUST still be declared, or it 405s.</p>
<p><strong>§8.4 <code>openapi-current</code>.</strong> Regenerate the OpenAPI subset from the binary and fail on any porcelain change. <em>Catches:</em> routes moving without the document moving — eight <code>plugin/ingress</code> paths silently absent from every generated SDK.</p>
<p><strong>§8.5 <code>zipdoc-current</code>.</strong> For every directory carrying the directive, run <code>zipdoc -check</code>. Additionally: every directory that registers a typed op MUST carry the directive. <em>Catches:</em> prose that can never reach the spec (six packages in cloud today, §4.1), and prose that has drifted from the comment it was lifted from.</p>
<p><strong>§8.6 <code>router-oracle</code></strong> (host-side, §3.5). Every declared route reaches its declaring plugin. <em>Catches:</em> two plugins claiming one path — at build time, not at first request, because <code>zip.Load</code> accepts the duplicate silently.</p>
<p><strong>§8.7 <code>tenancy</code>.</strong> No <code>In</code> type on any op has an <code>Org</code>/<code>Tenant</code>/<code>OrgID</code> field; every op that touches per-tenant state refuses when <code>zip.Tenant</code> returns <code>!ok</code>. <em>Catches:</em> cross-tenant read or bill via a caller-chosen org.</p>
<p><strong>§8.8 <code>the-suite-is-not-empty</code>.</strong> <code>go test ./... -json</code> MUST report a NON-ZERO number of executed tests, and every package MUST contribute at least one. <em>Catches:</em> a build tag excluding an entire suite while the command exits 0. <code>hanzoai/gateway</code> reported <code>build constraints exclude all Go files</code> on every tree, healthy or broken, for years — every file under <code>tests/</code> sat behind <code>//go:build legacy</code>, so the suite had NEVER executed and hid 12 real failures. A repo whose files carry build tags MUST run <code>./...</code> once per tag set (<code>make test</code> in gateway now runs a tagged and an untagged pass) and MUST assert both passes executed tests.</p>
<p><strong>§8.9 <code>ci-invokes-the-gate</code>.</strong> A test MUST assert that <code>hanzo.yml</code>&#x27;s <code>test:</code> block invokes <code>make test</code>. <em>Catches:</em> the failure that makes every gate above worthless. <code>hanzoai/cloud</code>&#x27;s CI never called <code>make test</code> at all, so gates added to the Makefile protected nobody; <code>hanzoai/gateway</code> had no workflow, so its <code>make test</code> was a gate in no pipeline. A gate that CI does not invoke is a comment.</p>
<p>Two properties every gate MUST hold, from §3.5 and repeated because they are the two ways a green tick lies:</p>
<ul><li><strong>Non-vacuity.</strong> A gate that examined nothing MUST fail, and MUST say how much</li></ul>
<p> it examined. Every route to zero examinations is a defect elsewhere that would otherwise arrive as a pass.</p>
<ul><li><strong>A source on one side.</strong> Never compare two derived artifacts. <code>weave_test.go</code></li></ul>
<p> compared a document to the document it protected, agreed with itself, and passed through 58 misroutes.</p>
<h3>§9 Every app is a plugin, and the bijection is enforced</h3>
<p>There is no second kind of app. <strong>Every app is a plugin and every plugin is an app</strong>, and the correspondence is one-to-one — not a convention, a gate.</p>
<p>Measured on 2026-08-04 in the reference host: <strong>120</strong> rows in the registry, <strong>120</strong> plugin directories carrying a <code>main</code>, <strong>120</strong> committed OpenAPI subsets. The four remaining directories under <code>plugin/</code> are declared tools, not apps, and are named in the generator&#x27;s exemption list.</p>
<ol><li>A repository that builds a plugin MUST appear exactly once in the host&#x27;s</li></ol>
<p> registry. A registry row MUST correspond to exactly one plugin.</p>
<ol><li>The host MUST enforce both directions mechanically and MUST hard-fail. The</li></ol>
<p> reference implementation is <code>make generate</code>, which scaffolds a missing <code>main</code> for a registered app and <strong>exits non-zero</strong> listing any plugin directory that has a <code>main</code> and no row.</p>
<ol><li>CI MUST additionally fail when generation produces any change, checked with</li></ol>
<p> <code>git status --porcelain</code> rather than a diff — porcelain catches a <em>new</em> untracked scaffold, which a diff does not.</p>
<p><strong>A gate that cannot fail does not count toward this.</strong> The reference host also carries a Go test named for this bijection which is vacuous: it skips any plugin <code>main</code> that does not call <code>cloud.Serve</code>, and that function was renamed to <code>cloud.Listen</code>, so it matches 0 of 120 mains and its loop body never executes. It passes unconditionally. Such a test MUST be deleted or repaired; leaving it is worse than having no test, because its name asserts coverage that does not exist. The bijection is genuinely enforced — by the generator, in CI — and that is the gate to point at.</p>
<h3>§10 Standalone is the same binary, not a mode</h3>
<p>A plugin MUST run alone. This is what makes &quot;build your own cloud&quot; a fact rather than a slogan: a third party takes one plugin, runs it, and has a working HIP-0119 service without adopting the host.</p>
<ol><li>Every plugin MUST have <code>package main</code> and MUST build to its own binary.</li><li>Run standalone, that binary MUST serve the same routes it serves as a child.</li></ol>
<p> There MUST NOT be a second code path — one server body, entered the same way, as §2 requires.</p>
<ol><li>The host MUST be able to build and load any single plugin without building the</li></ol>
<p> others.</p>
<p><strong>The enabled set MUST NOT be stated twice.</strong> A host derives which subsystem a child serves from the plugin it was built as. It MUST NOT additionally accept a flag or an environment variable restating that set.</p>
<p>This corrects a mechanism widely believed to exist: there is no <code>--enable</code> flag, and it MUST NOT be reintroduced. It was removed after two production outages on 2026-08-02, both caused by that list naming an app that did not exist and omitting one every other child needs. A build list — which plugins to compile — is a different thing from a mount list, and only the first is legitimate. The reference host&#x27;s <code>RUN_PLUGINS</code> is a build list and the binary takes no argument from it.</p>
<p>A deployment artifact still passing <code>--enable</code> is a live defect, not a harmless leftover: argument parsing is fatal on an unknown flag, so the process exits at startup. The reference host&#x27;s Helm chart still passes one and MUST stop.</p>
<h3>§11 Enable and disable are runtime, never a build tag</h3>
<p><strong>A capability that can be switched off MUST be a separate artifact the host loads, and MUST NOT be a build tag inside public source.</strong></p>
<p>A build tag leaks the shape of the private thing into the public repository — every reader sees the seams of what they are not getting — and it makes the open build a second-class citizen of its own repository, because the default build is the crippled one. It also multiplies the build matrix by the number of tags, which is how a repository acquires configurations nobody compiles.</p>
<p>Requirements:</p>
<ol><li>No <code>//go:build</code> tag MAY gate a paid, enterprise or optional capability.</li></ol>
<p> Measured in the reference host: zero such tags and zero <code>ee/</code> directories.</p>
<ol><li>An optional capability MUST ship as its own plugin binary, loaded by the host</li></ol>
<p> exactly as any other plugin is, and verified by the same digest.</p>
<ol><li>Enable and disable MUST be available at run time, per plugin, without a</li></ol>
<p> rebuild and without a restart of the host.</p>
<ol><li>A disabled plugin&#x27;s routes MUST remain registered and MUST answer <strong>503</strong>, not</li><li>A 404 says the route does not exist, which is false and sends the caller</li></ol>
<p> looking for a spelling mistake; 503 says it exists and is not currently serving.</p>
<ol><li>The control surface MUST be authenticated as an administrative operation and</li></ol>
<p> MUST be audited.</p>
<p>The reference host implements 3 through 5 at <code>/v1/admin/plugins</code> with <code>enable</code>, <code>disable</code> and <code>reload</code> per plugin.</p>
<p><strong>Reconciliation with HIP-0130.</strong> HIP-0130 (Draft) proposes a visible-source <code>ee/</code> tier inside the public repository as the paid boundary. That mechanism is a build-time gate in public source and contradicts this section. Where the two differ, this section governs, and HIP-0130&#x27;s tier-2 mechanism SHOULD be re-expressed as a separately-loaded artifact. The tier <em>boundary</em> HIP-0130 draws is not in dispute — only the mechanism that implements it. HIP-0135 remains authoritative on which repository a thing belongs in.</p>
<h3>§12 Discovery — one registry, one live answer</h3>
<p>A client such as an app builder MUST be able to enumerate the composition: which plugins exist, what each is called, what it serves, and whether it is running.</p>
<ol><li><strong>One registry.</strong> The set of apps and their order MUST come from the same</li></ol>
<p> in-code registry the OpenAPI pipeline projects from. There MUST NOT be a second list. In the reference host that registry is read by the mount loops, the build, the image, the generator and the admin surface alike.</p>
<ol><li><strong>Content comes from the router, never from the registry.</strong> The registry</li></ol>
<p> supplies the set and the order; what each plugin <em>serves</em> is projected from its own live router, per §4.2.</p>
<ol><li><strong>The host MUST serve <code>GET /v1/apps</code></strong>, answering from the plugins&#x27; own live</li></ol>
<p> declarations, fanned out in parallel to each child. Every zip app already serves its declaration at <code>/.well-known/zip/plugin.json</code> (§3), and hosts already own a parallel ask-every-child mechanism, so this endpoint requires no new artifact and no new source of truth.</p>
<ol><li><strong>It MUST NOT be a committed catalogue.</strong> A catalogue is a golden, and goldens</li></ol>
<p> drift silently: a committed tool list in this estate held 12 entries while the binary served 365.</p>
<ol><li>The response MUST carry, per app: name, whether it is running, its declared</li></ol>
<p> routes and ops, its artifact digest, and the identity fields of §13.</p>
<p><strong>State in the reference host:</strong> the declaration exists and is auto-served by every plugin; the host does not yet consume it, emits no declaration artifacts, and has no <code>/v1/apps</code>. Three adjacent endpoints exist and each reads the wrong process — a child answering about itself where the fleet was wanted, or a child answering about a plugin table only the host holds. §12.3 is the one that is correct by construction.</p>
<h3>§13 App identity — and the two places metadata dies</h3>
<p>Each app declares its customer-facing identity:</p>
<p>| Field | Meaning | Values | |---|---|---| | <code>Product</code> | the product a customer buys | one name | | <code>Category</code> | how it is grouped in a catalogue | one name | | <code>Kind</code> | what it <em>is</em> | <code>api</code>, <code>deployable</code>, <code>client</code> | | <code>Visibility</code> | who may see it listed | <code>internal</code> (default), <code>public</code> | | <code>Meters</code> | what it bills on | zero or more meter names |</p>
<p>Two rules, and the second is the one that bites.</p>
<p><strong>§13.1 Identity is declared in code, not in a comment.</strong> It MUST be fields on the registry&#x27;s own Go types. A doc comment cannot carry it: Go drops comments at compile time and reflection never sees them, so a comment reaches a document only via a build-time AST pass — and the pass that exists (§4.1) lifts <em>handler</em> doc comments into an operation&#x27;s description, examples and field help. It does not carry app identity, and extending it to do so would put identity in a second place. <code>Visibility</code> defaults to <code>internal</code>: a field that defaults to public publishes by omission, and the failure is unrecoverable.</p>
<p><code>Product</code> today is <em>derived</em> rather than declared — it is the first path segment after <code>/v1/</code> — and <code>Meters</code> has an existing precedent that MUST be reused rather than duplicated: the reference host already carries a required per-plugin price declaration whose zero value fails a test. Adding a second, parallel metering declaration would be exactly the defect this document exists to prevent.</p>
<p><strong>§13.2 A field with no Go name is silently deleted in transit.</strong> The published document is built by two closed-struct round-trips, and <strong>neither reports what it drops</strong>:</p>
<ol><li>A plugin&#x27;s open specification (<code>map[string]any</code>) is marshalled and then</li></ol>
<p> unmarshalled into a closed <code>Operation</code> struct. Unknown keys are ignored — unknown-field rejection is not enabled — and the re-marshal walks only the struct&#x27;s own fields.</p>
<ol><li>Each plugin&#x27;s committed subset is decoded into a closed <code>Document</code> struct,</li></ol>
<p> reaching the same <code>Operation</code>. There is no catch-all map and no extensions field at any level, and the weave then builds a <em>fresh</em> document from those values, so anything dropped at decode can never reappear downstream.</p>
<p><strong><code>x-app</code> survives, and it is the only extension that does</strong>, for exactly one reason: it is the only <code>x-</code> key with a named Go struct field (<code>App string \</code>json:&quot;x-app,omitempty&quot;\`<code>). Measured: 2,341 occurrences of </code>x-app<code> in the woven document and <strong>no other </code>x-` key at all</strong>, in the woven document or in any of the 120 subsets.</p>
<p>Therefore:</p>
<ul><li>Every field in the table above MUST be added as a **named field on both</li></ul>
<p> round-tripping structs** before it is populated anywhere.</p>
<ul><li>A conformance gate MUST assert each field survives a full projection, by</li></ul>
<p> reading it back out of the woven document rather than out of the source.</p>
<ul><li>Adding metadata as an unnamed extension is not a partial implementation. It</li></ul>
<p> produces a document that does not contain it, with no error at any stage, and the loss is invisible until a consumer looks for a field that was never there.</p>
<h3>§14 Fork a plugin, extend it, contribute back</h3>
<p>The point of the contract is that a plugin is an ordinary repository. Forking one therefore requires no permission and no coordination:</p>
<ol><li><strong>Fork.</strong> A plugin repository builds standalone (§10) and imports nothing of</li></ol>
<p> the host&#x27;s (§1.1), so a fork builds without access to the host at all.</p>
<ol><li><strong>Extend.</strong> Add typed ops. The four projections (§4) follow from the</li></ol>
<p> registration, so a new op reaches the specification, the tool list, the CLI and the call plane without touching any of them.</p>
<ol><li><strong>Run it.</strong> Point a host at the fork&#x27;s binary. The host loads a plugin by</li></ol>
<p> name, path or release index and verifies its digest; a fork is loaded exactly as the original is, and no host change is needed to try one.</p>
<ol><li><strong>Contribute back.</strong> A change is acceptable upstream when it satisfies the</li></ol>
<p> §Conformance checklist and every gate in §8. Those gates are the review: they are mechanical, they run in the fork&#x27;s own CI, and they are the same ones the original runs.</p>
<ol><li><strong>What upstream MUST NOT require.</strong> A contributor MUST NOT be asked to sign</li></ol>
<p> over more than the repository&#x27;s licence requires, to route the change through a private repository, or to reproduce a private artifact in order to build. A plugin that cannot be built and tested from public sources alone is not conforming, whatever else is true of it (HIP-0135).</p>
<h3>Conformance checklist</h3>
<p>Build a conforming plugin repo in one pass:</p>
<ol><li><code>go.mod</code> requires <code>github.com/zap-proto/zip &gt;= v1.18.7</code>, plus</li></ol>
<p> <code>hanzoai/plane</code> if it calls a peer — not yet fetchable, see §1.3(a) — and <code>hanzoai/money</code> if it handles money. Nothing from <code>hanzoai/cloud</code>. §8.1 proves it.</p>
<ol><li>One <code>main</code> per §2: construct, register typed ops, register peer ops on the</li></ol>
<p> second app, <code>zip.Described()</code> check, <code>app.Listen(zip.Addr(fallback))</code>.</p>
<ol><li><code>//go:generate go run github.com/zap-proto/zip/cmd/zipdoc</code> in every package</li></ol>
<p> registering a typed op; <code>zipdoc_gen.go</code> committed.</p>
<ol><li>Every op typed, with an explicit <code>WithOperationID</code>; untyped handlers only</li></ol>
<p> where the response cannot be a value.</p>
<ol><li><code>&lt;binary&gt; openapi &lt;file&gt;</code> and <code>&lt;binary&gt; declare &lt;file&gt;</code> both work and both</li></ol>
<p> write files. Both artifacts committed and regenerated by <code>make test</code>.</p>
<ol><li>No <code>Org</code> field in any <code>In</code>; <code>zip.Tenant(ctx)</code> with refusal on <code>!ok</code>.</li><li>HIP-0119 in full: app listener <code>:8000</code>/<code>PORT</code>, <code>/v1/</code> only, ops listener</li></ol>
<p> <code>:9090</code>/<code>OPS_PORT</code> with <code>/healthz</code> + <code>/readyz</code> + <code>/metrics</code>, zero required flags, secrets from KMS, nothing from HIP-0119 §9.</p>
<ol><li>Root <code>hanzo.yml</code> with <code>binaries:</code> and a <code>test:</code> block that runs <code>make test</code>;</li></ol>
<p> a seven-line <code>.github/workflows/cicd.yml</code> importing <code>hanzoai/ci</code>.</p>
<ol><li>Every gate in §8, all reachable from <code>make test</code>, and §8.9 proving CI calls</li></ol>
<p> it.</p>
<ol><li>Tags minted by the pipeline after publish (§7.1). Patch bumps only.</li><li>Exactly one registry row, and <code>make generate</code> clean — §9. The plugin builds</li></ol>
<p> and serves ALONE, with no second code path and no flag restating which app it is — §10.</p>
<ol><li>No build tag gates an optional capability; enable and disable work at run</li></ol>
<p> time and a disabled route answers 503 — §11.</p>
<ol><li>App identity (<code>Product</code>, <code>Category</code>, <code>Kind</code>, <code>Visibility</code>, <code>Meters</code>) declared</li></ol>
<p> as named Go fields, and each one read back out of the WOVEN document to prove it survived both round-trips — §13.</p>
<h2>The API surface a composition serves</h2>
<p>These sections describe the API a composition presents to callers — the credential, the meter and the OpenAI-compatible endpoint — not the plugin contract above. They are filed here because the HIPs that owned them were merged into this document; they constrain what a plugin serving those surfaces must do, and they are unchanged by the composition model.</p>
<h3>API keys</h3>
<p>The credential for programmatic access is an API key. IAM mints and verifies it, <code>gateway</code> resolves it to a principal at the edge, and no subsystem downstream reads it again. There are two types, and the prefix is what every consumer switches on:</p>
<p>| Type | Prefix | Where it belongs | |---|---|---| | publishable | <code>pk-</code> | browser and client code; identifies an org, authorizes nothing that spends | | secret | <code>sk-</code> | server side only; carries the caller&#x27;s full scope |</p>
<p><code>hk-</code> was the older name for a secret key. Nothing has minted one since <code>iam</code> v1.33.9, and verification no longer accepts one.</p>
<pre><code>GET /v1/keys # the caller&#x27;s keys: { type, prefix, createdAt }
POST /v1/keys # mint or rotate the key of { type }
DELETE /v1/keys # revoke the key of that type</code></pre>
<p><strong>The secret is returned exactly once, at mint.</strong> Every later read returns type, prefix and creation time. What is stored is a hash of the key, never the key — a plaintext credential at rest is a defect, not a configuration choice. The subject a key is minted for is derived from the validated identity headers and never from the request body, so a caller can mint and revoke only their own.</p>
<p>A key carries a scope, and the scope is enforced at the gateway edge before any subsystem sees the request:</p>
<p>| Field | Meaning | |---|---| | <code>models</code> | which models the key may address; <code>*</code> for all | | <code>services</code> | which subsystems it may invoke — <code>llm</code>, <code>agents</code>, <code>mcp</code>, <code>embeddings</code>, <code>images</code>, <code>audio</code> | | <code>rateLimit</code> | requests per minute; default 60 | | <code>spendLimit</code> | ceiling in USD cents per billing period; unset means the org balance is the only ceiling | | <code>allowedIPs</code> | CIDR allowlist; unset means any address | | <code>expiresAt</code> | expiry; unset means the key lives until revoked |</p>
<h3>Credit metering</h3>
<p>Spend is prepaid. An org buys credits and every priced request draws the balance down, so spend cannot exceed what was bought and there is no surprise bill. One credit is one US cent — the arithmetic and the display are the same unit. One balance covers every subsystem: inference, agent runs, MCP tool calls, storage.</p>
<p><code>commerce</code> owns the balance. The metering client is the one place this binary asks about money, and it wraps every priced request in two calls:</p>
<ol><li><strong>Authorize</strong>, before the handler runs. Sufficient balance passes.</li></ol>
<p> Insufficient balance is <code>402 insufficient_balance</code> and the handler never runs. An unreachable <code>commerce</code> is <code>503 balance_unavailable</code>.</p>
<ol><li><strong>Record</strong>, after the handler returns, with the units the request</li></ol>
<p> actually consumed.</p>
<p><strong>Fail-closed is the default</strong>: when <code>commerce</code> cannot be reached the request is denied rather than served unpriced. Fail-open is a deliberate per-deployment choice, never the consequence of an outage. Free routes declare a price of zero and skip both calls.</p>
<p>A usage event says who spent and what it cost, exactly. The wire type the recorder carries is deliberately narrow — subject, namespace, an EXACT decimal USD (never a rounded cent), currency, model and provider (<code>hanzoai/cloud</code> <code>ai.go:23-30</code>) — and it carries no idempotency ref, an absence that is load-bearing: the ref this struct once carried was derived from client-posted fields and handed the ledger&#x27;s dedup key to the payer. It carries no prompt content and no PII. The per-request detail (tokens, latency, per-model breakdowns) lives in the <code>hanzo.cloud_usage</code> warehouse ledger the ai plane writes; the money lands on the org&#x27;s commerce ledger.</p>
<p>The <code>usage</code> capability is the categorized read over that record, and it is specified in HIP-1313.</p>
<h3>OpenAI-compatible surface</h3>
<p>The inference surface is OpenAI&#x27;s, so an existing application moves by changing two strings:</p>
<pre><code class="lang-python">from openai import OpenAI
client = OpenAI(
api_key=&quot;sk-...&quot;,
base_url=&quot;https://api.hanzo.ai/v1&quot;,
)
response = client.chat.completions.create(
model=&quot;zen-8b-instruct&quot;,
messages=[{&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: &quot;Hello&quot;}],
)</code></pre>
<pre><code>POST /v1/chat/completions # streaming and non-streaming
POST /v1/completions # legacy
POST /v1/embeddings
POST /v1/images/generations
POST /v1/audio/transcriptions
POST /v1/audio/translations
GET /v1/models</code></pre>
<p>The <code>ai</code> subsystem holds the model catalog and the routing policy; <code>gateway</code> speaks the OpenAI shape at the edge and absorbs provider-specific differences. Both are subsystems of this binary, so a request arriving at <code>/v1/chat/completions</code> is authenticated, authorized against the balance, routed, served and recorded without leaving the process.</p>
<h3>Deployment surfaces this enables</h3>
<p>| Deployment | Brand | Enabled subsystems | Domain | |---|---|---|---| | Hanzo flagship | hanzo | all | api.hanzo.ai | | Osage Cloud | osage | iam, base, kms, commerce, ai, gateway, o11y, vfs | api.osage.cloud | | Lux Cloud | lux | iam, base, kms, gateway, chain | api.lux.cloud | | Zoo Cloud | zoo | iam, base, kms, ai, gateway, vfs | api.zoo.cloud | | Customer X (reseller) | custom | iam, base, kms, commerce, gateway | api.x.com |</p>
<p>Same image. Different startup configuration. The <code>osage.cloud</code> marketing site that shipped 2026-05-19 gets a real backend when this HIP lands.</p>
<h2>Commerce — light router, NOT in PCI-DSS scope</h2>
<p><strong>Commerce is a thin orchestrator.</strong> It owns the customer-facing checkout flow, tenant config, billing logic, pricing logic, invoicing, and webhook intake. It explicitly does NOT:</p>
<ul><li>Touch a Primary Account Number (PAN)</li><li>Process card data</li><li>Implement processor connector logic (native PSP SDK /</li></ul>
<p> Adyen SDK)</p>
<ul><li>Store encrypted PAN</li></ul>
<p>Commerce only handles <strong>tokens</strong> (vault tokens) and <strong>intents</strong> (payments-orchestrator references). When commerce needs to charge, it calls <code>payments</code> (Rust) via ZAP RPC with a token + amount + processor hint. Payments calls <code>vault</code> (Go) via ZAP RPC with a &quot;Charge this token&quot; request; vault pulls the PAN from its encrypted store, makes the outbound HTTPS to the processor, and returns the response. <strong>PAN never leaves vault.</strong></p>
<p>This makes commerce <strong>CDE-connected</strong>, not <strong>CDE</strong>. Lighter controls apply (network segmentation, access control, change management) but commerce is NOT subject to PCI-DSS L1 audit.</p>
<h2>Solo-vault CDE</h2>
<p><strong>Vault is the only system in PCI-CDE.</strong> Per the corrected scope:</p>
<p>| System | PCI scope | |---|---| | <code>vault</code> | <strong>CDE</strong> — the only system that touches PAN. Full L1 audit. Quarterly ASV. HSM-backed key store. Own deployment, own k8s namespace, own NetworkPolicy boundary. | | <code>payments</code> | <strong>CDE-connected</strong> (NOT CDE). Sees only tokens. Payments service operated in tokens-only mode. Calls <code>vault.Charge(token, processor, amount)</code> for the actual processor call. | | <code>commerce</code> | <strong>CDE-connected</strong> (NOT CDE). Light router. Only ever handles tokens + intent IDs. Mounts inside cloud like any other subsystem. | | Everything else in cloud | <strong>Not CDE-connected.</strong> Standard SOC2-grade controls. |</p>
<p>For this architecture to be sound, two requirements must hold:</p>
<ol><li><strong>Browser-side card collection runs directly against vault</strong> (vault</li></ol>
<p> ships a <code>vault-collect.js</code> iframe; PAN posts directly to vault from the browser, never via commerce or any Hanzo app server).</p>
<ol><li><strong>Payments runs in tokens-only mode</strong> — verified by</li></ol>
<p> audit of payments data flow that no code path exposes raw PAN to the surrounding Go process.</p>
<p>Both are tracked under the implementation TODO list at <code>~/work/hanzo/vault/docs/</code> (to be created).</p>
<h2>PSP optionality</h2>
<p>The same architecture supports four deployment modes:</p>
<ol><li><strong>Default (Hanzo as merchant)</strong>: Hanzo operates vault + payments +</li></ol>
<p> commerce. Hanzo bears the PCI-DSS L1 audit. PCI scope = vault only.</p>
<ol><li><strong>Hanzo as PSP for a white-label customer</strong>: customer&#x27;s brand</li></ol>
<p> (<code>lux.cloud</code>, <code>zoo.cloud</code>, <code>osage.cloud</code>) runs commerce inside their cloud deployment; commerce&#x27;s <code>payments_client</code> and <code>vault_client</code> ZAP endpoints point at Hanzo&#x27;s payments + vault. Customer carries no PCI obligation. Hanzo&#x27;s vault has multi-tenant token namespacing per org.</p>
<ol><li><strong>Customer brings their own PSP backend</strong>: customer deploys their own</li></ol>
<p> vault + payments. Their cloud&#x27;s commerce subsystem points its ZAP-RPC endpoints at THEIR vault + payments deployment. <strong>Hanzo carries no PCI obligation for that customer&#x27;s flows.</strong> The customer holds their own PCI scope. Commerce is a swappable thin router.</p>
<ol><li><strong>Single-tenant Hanzo Payments-as-a-product</strong>: customer&#x27;s ENTIRE</li></ol>
<p> commercial unit is payment-processing. Deploy payments + vault + a trimmed cloud as a unit. Commerce still operates as light router — no design change, only deployment shape.</p>
<p>Modes 1-3 share the same binary. Configuration determines which endpoints commerce talks to. The &quot;swappable thin router&quot; property is load-bearing: commerce never grows code that depends on a specific vault or payments operator.</p>
<h2>Non-goals</h2>
<ul><li><strong>TS service rewrite as part of this HIP.</strong> Platform (Next.js /</li></ul>
<p> Dokploy fork), brain (where still TS), bot, billing, pricing (separate Go rewrites slated under commerce subsumption). They can be ported to Go later if performance or operations require it; this HIP does not block on them.</p>
<ul><li><strong><code>vault</code> and <code>payments</code> are explicitly NOT folded.</strong> Both stay as</li></ul>
<p> their own deployments with their own PCI scope boundaries per the &quot;Solo-vault CDE&quot; section above. Vault is CDE. Payments is CDE-connected. Commerce talks to both via ZAP RPC. <strong>Hard rule, no exceptions</strong> — even single-tenant deployments use the three-process architecture.</p>
<ul><li><strong><code>~/work/hanzo/flow</code> (Hanzo Flow — visual ML pipeline / agent-building) is NOT folded.</strong> Visual ML</li></ul>
<p> pipeline / agent-building tool. Heavy native deps (torch, faiss, sentence-transformers). Runs as a separate process behind the gateway subsystem. Per the FT audit (2026-05-19), classified RED — defer to GIL-Python until torch ships cp313t (&gt;=2.6).</p>
<ul><li><strong><code>~/work/hanzo/datastore</code> (Hanzo Datastore fork) is NOT folded.</strong> OLAP</li></ul>
<p> column store. Uses Hanzo Datastore-native ReplicatedMergeTree + S3 disk. Out of scope. Shares S3 bucket with HIP-0107 streaming via vfs prefix (<code>s3://bucket/datastore/...</code> vs <code>s3://bucket/replicate/...</code>).</p>
<ul><li>**<code>~/work/hanzo/insights</code> (Hanzo Insights — AI observability + eval + prompt management) is NOT</li></ul>
<p> folded.** Runs as a separate process — the canonical AI console for cloud-hosted LLM operations. Integrates with cloud via HTTP + (forthcoming) ZAP-typed endpoints; consumed by the <code>cloud</code> subsystem (LLM control plane) and surfaced to operators as part of the AI console.</p>
<ul><li>**Other Python services flagged RED by the 2026-05-19 free-threading</li></ul>
<p> audit** (<code>cli</code>, <code>erp</code>, <code>insights</code>, <code>sentry</code>, <code>studio</code>) — all stay separate processes until their upstream FT-blockers clear (xmlsec, confluent-kafka, chdb, single-threaded Django/Celery assumptions, torch &lt;2.6). Run under regular <code>python3.13</code> (GIL-enabled) until then.</p>
<ul><li><strong>Cross-deployment service mesh.</strong> The unified binary collapses</li></ul>
<p> in-deployment service calls; cross-deployment (Hanzo ↔ Lux ↔ Zoo) stays on the existing service-discovery + bridge layer.</p>
<ul><li><strong>Auto-scaling per-subsystem.</strong> All subsystems in one binary scale</li></ul>
<p> together. If a subsystem becomes a hot bottleneck, fall back to running it as its own binary alongside the unified one — the Mount contract supports both.</p>
<h2>Open questions</h2>
<ol><li><strong>Cold start of a lazy composition.</strong> An eager host pays 116 processes at</li></ol>
<p> boot; a lazy one pays the first request. The cost of the first request to a cold plugin is unmeasured per plugin, and <code>CLOUD_PLUGIN_START</code> (90s default, raised from zip&#x27;s 10s because a plugin that opens stores and runs migrations on a cold volume misses it) is a blunt instrument. Needs a per-plugin measurement before a latency-critical prefix is left lazy.</p>
<ol><li><strong>Finer plugins make the build WORSE until the floor drops.</strong> Each plugin</li></ol>
<p> binary is ~40 MB of which ~35 MB is the core every other plugin also links. Splitting one capability into two plugins duplicates that core again. The sequencing rule is therefore: drop the floor first (§1.3), split second.</p>
<ol><li><strong>Extension schemas.</strong> A <code>Module</code> route registers a route and no op, so it is</li></ol>
<p> in no document, is no MCP tool and is reachable by no peer (§5). Closing it requires an extension that DECLARES its contract in its <code>extension.json</code>, and <code>zip.Module</code> surfacing that schema so the projections follow. Until an extension declares one there is nothing to project.</p>
<ol><li><strong>Remote ZAP.</strong> The call plane is unix sockets today. A plugin composed</li></ol>
<p> across hosts needs ZAP over TCP with session crypto and a non-Go client; both are open work in <code>zap-proto</code>. <code>CLOUD_&lt;NAME&gt;_ADDR</code> works over a trusted network in the meantime, which is a deployment constraint, not a contract.</p>
<ol><li><strong>Third-party plugins.</strong> Every rule here is enforced by a gate the host runs</li></ol>
<p> over an artifact the host verified, which is sufficient for first-party repos. An untrusted plugin additionally needs a resource bound and a capability restriction on the child process; neither is specified here.</p>
<h2>References</h2>
<ul><li>HIP-0119 — Hanzo Service Conventions — **the service shape a plugin conforms</li></ul>
<p> to in full; this HIP adds only what HIP-0119 does not cover**</p>
<ul><li>HIP-0106 — Plugin &amp; VM Model — <strong>SUPERSEDED by this HIP.</strong> Its surviving</li></ul>
<p> truths are absorbed here: no build tags (a capability is a plugin, compiled once, loaded when asked); a plugin is a supervised child with crash isolation and per-prefix 503 degradation; ZAP is only a transport, and reachability confers no authority. Its lpm distribution, its <code>.zap</code>/<code>zapc</code> plugin IDL and its &quot;embedded subsystem&quot; shape did not ship and are replaced by §3 (the declaration), §7 (<code>hanzoai/ci</code> + <code>binaries.json</code> + digest-verified install) and §1.3(a) (<code>hanzoai/plane</code>, a Go leaf of op names and types)</p>
<ul><li>HIP-0105 — In-Process Extension Runtime — the engines §5 makes opt-in</li><li>HIP-0134 — One Process, One Socket, One Identity — **where the principal comes</li></ul>
<p> from, and the rule that nothing re-derives it.** §1.3(b) and §6 cite it and add only the plugin&#x27;s own read; they do not restate it</p>
<ul><li>HIP-0026 / HIP-0111 — IAM: the authority §1.3(b) forbids a plugin from</li></ul>
<p> duplicating</p>
<ul><li>HIP-0027 — KMS: where §1.3(c)&#x27;s key comes from</li><li>HIP-0132 — One Telemetry Plane: what §1.3(e)&#x27;s sink reports to</li><li>HIP-0036 — CI/CD: the <code>hanzo.yml</code> + <code>hanzoai/ci</code> lanes §7 uses</li><li>HIP-0114 — ZAP: envelope, framing and authentication of the call plane</li><li>HIP-0122 — zip: the application server core every shape mounts on</li><li>HIP-0130 / HIP-0135 — the OSS/private line, and what is public: consumers of</li></ul>
<p> this contract, not restatements of it</p>
<ul><li>HIP-0117 — Cloud-in-a-Box: the deployment topologies a composition serves</li><li>HIP-0302 / HIP-0107 — per-tenant encrypted storage and its replication</li><li>HIP-0400 — Service CRD: how a composition is deployed</li><li><code>hanzoai/cloud</code> <code>LLM.md</code> — the reference host&#x27;s own tree: <code>manifest/</code>,</li></ul>
<p> <code>plugin/&lt;app&gt;/</code>, <code>mk/plugin.mk</code>, <code>openapi/weave.go</code>. It states how cloud implements this contract and MUST NOT restate the contract itself</p>
<ul><li><code>github.com/zap-proto/zip</code> <code>LLM.md</code> — the framework&#x27;s own surface</li></ul>
<footer>
<div class="fmap">
<div><b>Build</b>
<a href="https://hanzo.app">hanzo.app</a> app builder
<a href="https://hanzo.codes">hanzo.codes</a> code with an agent
<a href="https://hanzoskills.com">hanzoskills.com</a> what an agent reads</div>
<div><b>Run</b>
<a href="https://console.hanzo.ai">console.hanzo.ai</a> cloud console
<a href="https://api.hanzo.ai">api.hanzo.ai</a> the API</div>
<div><b>Account</b>
<a href="https://hanzo.id">hanzo.id</a> sign in
<a href="https://pay.hanzo.ai">pay.hanzo.ai</a> top up
<a href="https://billing.hanzo.ai">billing.hanzo.ai</a> invoices and usage</div>
<div><b>Company</b>
<a href="https://hanzo.ai">hanzo.ai</a> canonical
<a href="https://hanzo.ventures">hanzo.ventures</a> ventures</div>
</div>
<div class="fend"><a href="/hip-0106.md">This page as plain text</a> · <a href="/llms.txt">Index for agents</a></div>
</footer>
</div></body></html>