mirror of
https://github.com/hanzoai/skills.git
synced 2026-11-19 00:47:36 +00:00
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]>
379 lines
32 KiB
HTML
379 lines
32 KiB
HTML
<!doctype html>
|
|
<html lang="en"><head>
|
|
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
<title>hip-0063</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-0063.md">
|
|
|
|
<link rel="icon" href="/favicon.svg">
|
|
<link rel="canonical" href="https://hanzoskills.com/hip-0063">
|
|
</head>
|
|
<!-- Reading this with a machine? Every page here is also plain markdown.
|
|
This one: https://hanzoskills.com/hip-0063.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-0063</h1><p class="lede">HIP-63: Feature Flags Standard. Status Final. Hanzo architectural specification.</p><h1>HIP-0063: Feature Flags Standard</h1>
|
|
<h2>Abstract</h2>
|
|
<p>This proposal defines the feature flag platform for the Hanzo ecosystem. Hanzo Flags provides boolean flags, multivariate flags, percentage rollouts and user targeting — the primitive every other plane composes, including the AI-specific splits that make model routing, prompt selection and retrieval strategy switchable without a deploy.</p>
|
|
<p>Evaluation semantics are PostHog-compatible — the embedded evaluator is pinned to a 621-case parity table (<code>apps/flags/engine.go:11-13</code>) — so a PostHog-shaped client repoints by changing the host. An OpenFeature adapter, if published, wraps the generated SDK rather than defining the wire.</p>
|
|
<p>The A/B plane that composes this primitive — the experiment registry, its analysis and its decision — is the separate <code>experiment</code> capability, HIP-1311.</p>
|
|
<p><strong>Evaluator</strong>: <a href="https://github.com/hanzoai/flags">github.com/hanzoai/flags</a> — the stateless Go engine (<code>flags/go</code>) compiled into the cloud binary <strong>Serving</strong>: <code>apps/flags</code> in <code>hanzoai/cloud</code>, at <code>/v1/flags</code> — there is no standalone flags service, port or image; SDK access is the generated cloud SDKs (HIP-1030)</p>
|
|
<h2>Motivation</h2>
|
|
<p>Every software team eventually needs to decouple deployment from release. You push code to production, but the new behavior is hidden behind a flag. You turn it on for 1% of users, watch metrics, then ramp to 100%. If something breaks, you kill the flag -- no rollback, no redeployment, no incident.</p>
|
|
<p>This is table stakes for web applications. But AI systems introduce a category of experimentation that traditional feature flag platforms were never designed for:</p>
|
|
<ol><li><strong>Model version rollouts</strong>: You have Zen-72B in production. Zen-120B is ready. You want to route 5% of inference traffic to the new model, compare quality scores, latency, and cost, then decide whether to promote. This is not a boolean flag -- it is a traffic split with multi-dimensional metric analysis.</li></ol>
|
|
<ol><li><strong>Prompt template A/B testing</strong>: The same model with two different system prompts produces different outputs. Which prompt yields better user satisfaction? Better task completion? Lower token usage? You need to randomly assign users to prompt variants and track downstream metrics.</li></ol>
|
|
<ol><li><strong>RAG strategy comparison</strong>: Retrieval-augmented generation has multiple knobs -- chunk size, overlap, embedding model, reranker, top-k. Comparing strategies requires running parallel pipelines and measuring answer quality. This is a multi-armed bandit problem, not a simple on/off switch.</li></ol>
|
|
<ol><li><strong>Cost optimization experiments</strong>: Route 20% of traffic to a cheaper model. If quality metrics remain within the baseline, promote the cheaper model for that traffic segment.</li></ol>
|
|
<p>General-purpose flag platforms treat flags as configuration switches for UI elements, and their evaluation rides a hosted tier — a CDN poll or a streaming connection — that can go stale. For AI inference routing, a stale flag is a request routed to a deprecated model or a cost tier over budget. Hence the design: a stateless, PostHog-compatible evaluator compiled into the cloud binary, definitions in each org's own encrypted SQLite, with no evaluation tier that can go stale.</p>
|
|
<h2>Specification</h2>
|
|
<h3>The shipped surface</h3>
|
|
<p><strong>flags</strong> (<code>manifest/apps.go:54</code>) serves seven operations under <code>/v1/flags</code> (<code>apps/flags/routes.go:47-60</code>): <code>POST /v1/flags</code> and <code>POST /v1/flags/decide</code> are the SAME evaluate handler — one verdict function, two spellings for the PostHog-shaped clients; <code>GET /v1/flags/defs</code>, <code>GET|PUT|DELETE /v1/flags/defs/{key}</code> manage definitions; <code>GET /v1/flags/activity</code> reads the audit log; <code>GET /v1/flags/health</code> probes. Definitions live in per-(org, project) encrypted SQLite — <code>{DataDir}/orgs/{org}/projects/{project}/flags.db</code> via <code>cloud.OrgDB</code> (<code>apps/flags/store.go:3-6</code>) — and evaluation runs in-process through the embedded evaluator <code>github.com/hanzoai/flags/go</code>, a pure function of (definitions JSON, context JSON) answering in microseconds (<code>apps/flags/engine.go:1-13</code>). <strong>No KV, no sync protocol, no network hop</strong>: every pod evaluates from its own hot copy, which is what makes the p99 targets below ordinary rather than aspirational.</p>
|
|
<p>The credential is the org's ordinary bearer per HIP-0026 — there is no <code>hf_*</code> key family. The admin plane is not a second prefix: definition writes are org-scoped on the same surface, and the platform's own switches are the reserved platform store the SuperAdmin flips from the cockpit through the same engine (<code>apps/flags/flags.go:21-27</code>).</p>
|
|
<p>Stated for HIP-0139 §6: the capability is <strong>free</strong>, said in those words (<code>plugin/flags/main.go:21</code> — <code>Price: cloud.Free</code>), and <code>/v1/flags/</code> is on the spend gate's never-refuse list (<code>spend.go:453</code>) because the kill switch must be observable by an unpaid org. It owns the definition store above and no other. It publishes <strong>no events</strong> on the bus, so a customer's webhooks (HIP-1310) receive nothing from it, and it emits nothing to observability beyond the request span. It is <strong>ga</strong> (HIP-0139 §8): flags is the mechanism stage-gating itself rides, so it cannot sit behind a flag. Upstream: it embeds <code>github.com/hanzoai/flags/go</code>, our own implementation of PostHog-compatible evaluation semantics, pinned to the prior implementation's answers by a 621-case parity table (<code>apps/flags/engine.go:11-13</code>).</p>
|
|
<h3>Flag Types</h3>
|
|
<p>Hanzo Flags supports four flag value types, matching the OpenFeature specification:</p>
|
|
<p>| Type | Use Case | Example | |------|----------|---------| | <strong>Boolean</strong> | Kill switches, feature gates | <code>new-dashboard: true/false</code> | | <strong>String</strong> | Multivariate experiments, model selection | <code>inference-model: "zen-72b" / "zen-120b"</code> | | <strong>Number</strong> | Numeric configuration, thresholds | <code>rate-limit-multiplier: 1.5</code> | | <strong>Object</strong> | Complex configuration, prompt templates | <code>rag-config: {"chunk_size": 512, "top_k": 5}</code> |</p>
|
|
<h3>Flag Definition Schema</h3>
|
|
<p>The stored definition is the PostHog-compatible JSON the embedded evaluator consumes (<code>apps/flags/store.go:5</code>), versioned and audited; the evaluator's parity table, not this document, is the normative statement of its fields. The JSON below illustrates the concepts a definition carries — variants, targeting, rollout percentages, a fallthrough — in a reader-friendly shape:</p>
|
|
<pre><code class="lang-json">{
|
|
"key": "inference-model-experiment",
|
|
"name": "Inference Model A/B Test",
|
|
"description": "Compare Zen-72B vs Zen-120B on production traffic",
|
|
"type": "string",
|
|
"defaultValue": "zen-72b",
|
|
"enabled": true,
|
|
"targeting": {
|
|
"rules": [
|
|
{
|
|
"name": "Internal dogfood",
|
|
"priority": 1,
|
|
"conditions": [
|
|
{"attribute": "org", "op": "in", "value": ["hanzo", "zoo"]}
|
|
],
|
|
"variant": "zen-120b"
|
|
},
|
|
{
|
|
"name": "Pro users 20% rollout",
|
|
"priority": 2,
|
|
"conditions": [
|
|
{"attribute": "plan", "op": "eq", "value": "pro"}
|
|
],
|
|
"rollout": {
|
|
"percentages": {"zen-72b": 80, "zen-120b": 20},
|
|
"seed": "inference-model-experiment"
|
|
}
|
|
}
|
|
],
|
|
"fallthrough": {
|
|
"variant": "zen-72b"
|
|
}
|
|
},
|
|
"variants": {
|
|
"zen-72b": {"value": "zen-72b"},
|
|
"zen-120b": {"value": "zen-120b"}
|
|
},
|
|
"metadata": {
|
|
"owner": "ml-team",
|
|
"jira": "ML-1234",
|
|
"experiment_id": "exp_model_comparison_2026Q1"
|
|
}
|
|
}</code></pre>
|
|
<h3>Targeting Rules</h3>
|
|
<p>Targeting determines which variant a user receives. Rules are evaluated top-to-bottom by priority; the first matching rule wins.</p>
|
|
<h4>Condition Operators</h4>
|
|
<p>| Operator | Description | Example | |----------|-------------|---------| | <code>eq</code> | Equals | <code>{"attribute": "plan", "op": "eq", "value": "pro"}</code> | | <code>neq</code> | Not equals | <code>{"attribute": "plan", "op": "neq", "value": "free"}</code> | | <code>in</code> | In set | <code>{"attribute": "org", "op": "in", "value": ["hanzo", "zoo"]}</code> | | <code>not_in</code> | Not in set | <code>{"attribute": "country", "op": "not_in", "value": ["CN", "RU"]}</code> | | <code>gt</code>, <code>gte</code>, <code>lt</code>, <code>lte</code> | Numeric comparison | <code>{"attribute": "account_age_days", "op": "gte", "value": 30}</code> | | <code>contains</code> | String contains | <code>{"attribute": "email", "op": "contains", "value": "@hanzo.ai"}</code> | | <code>regex</code> | Regex match | <code>{"attribute": "user_agent", "op": "regex", "value": "Mobile.*"}</code> | | <code>semver_gt</code>, <code>semver_lt</code> | Semantic version | <code>{"attribute": "app_version", "op": "semver_gt", "value": "2.1.0"}</code> |</p>
|
|
<h4>Targeting Dimensions</h4>
|
|
<pre><code class="lang-yaml">User Attributes:
|
|
- user_id / distinct_id # Stable user identifier
|
|
- email # Email-based targeting
|
|
- org / organization # Organization membership
|
|
- plan # Subscription tier (free, pro, enterprise)
|
|
- account_age_days # Days since signup
|
|
- country / region # GeoIP-derived (from request IP)
|
|
- language # Accept-Language header
|
|
|
|
Device Attributes:
|
|
- device_type # Desktop, Mobile, Tablet
|
|
- os # macOS, Windows, Linux, iOS, Android
|
|
- browser # Chrome, Firefox, Safari
|
|
- app_version # Semantic version of client app
|
|
|
|
AI-Specific Attributes:
|
|
- model_requested # Model the user requested
|
|
- token_budget # User's remaining token budget
|
|
- request_complexity # Estimated prompt complexity (token count)
|
|
- provider_preference # User's preferred AI provider</code></pre>
|
|
<h4>Percentage Rollouts</h4>
|
|
<p>Percentage-based rollouts use consistent hashing on a stable identifier (typically <code>user_id</code> + flag key). This ensures a user always receives the same variant for a given flag, even across multiple evaluations, multiple servers, and service restarts.</p>
|
|
<pre><code>hash = murmur3(user_id + ":" + flag_key + ":" + seed)
|
|
bucket = hash % 10000 // 0-9999, giving 0.01% granularity</code></pre>
|
|
<p>The seed is configurable per flag. Changing the seed reshuffles the assignment -- useful when you want to run a new experiment on the same flag key without the previous assignment biasing results.</p>
|
|
<h3>Evaluation API</h3>
|
|
<h4>POST /v1/flags/decide</h4>
|
|
<p>Evaluate flags for an identity. This is the primary hot-path endpoint — served as both <code>POST /v1/flags</code> and <code>POST /v1/flags/decide</code>, one handler (<code>apps/flags/routes.go:52-55</code>). It answers for EVERY flag in the caller's definitions at once (the PostHog <code>/decide</code> shape), so there is no separate batch endpoint to keep in step with it.</p>
|
|
<pre><code class="lang-http">POST /v1/flags/decide HTTP/1.1
|
|
Host: api.hanzo.ai
|
|
Authorization: Bearer <the org's ordinary key, HIP-0026>
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"distinct_id": "user_789",
|
|
"properties": {
|
|
"org": "hanzo",
|
|
"plan": "pro",
|
|
"country": "US"
|
|
}
|
|
}</code></pre>
|
|
<p>Response:</p>
|
|
<pre><code class="lang-json">{
|
|
"key": "inference-model-experiment",
|
|
"value": "zen-120b",
|
|
"variant": "zen-120b",
|
|
"reason": "TARGETING_MATCH",
|
|
"rule_id": "internal-dogfood",
|
|
"metadata": {
|
|
"experiment_id": "exp_model_comparison_2026Q1"
|
|
}
|
|
}</code></pre>
|
|
<p>The response and reason vocabulary is the embedded evaluator's — PostHog-compatible, pinned by its parity table — and the JSON above is illustrative of the verdict's shape (state, variant, payload per flag), not a schema this HIP owns: the definitive shape is what the evaluator answers and the served document publishes (HIP-1030).</p>
|
|
<h4>Performance Requirements</h4>
|
|
<p>| Metric | Target | |--------|--------| | Evaluation latency (p50) | < 1ms | | Evaluation latency (p99) | < 5ms | | Batch evaluation (10 flags, p99) | < 10ms | | Availability | 99.99% | | Throughput | 100K evaluations/second per node |</p>
|
|
<p>These targets are achievable because flag evaluation is a pure in-memory operation: definitions are read from the org's own SQLite store into a hot in-process copy, and the evaluator is a pure function over them (<code>apps/flags/engine.go:5-7</code>). There is no KV tier and no sync hop to go stale.</p>
|
|
<h3>Management surface</h3>
|
|
<p>Definition management is org-scoped on the SAME prefix — there is no <code>/admin/v1</code> and no separate management key family:</p>
|
|
<pre><code>GET /v1/flags/defs # list definitions
|
|
GET /v1/flags/defs/{key} # read one
|
|
PUT /v1/flags/defs/{key} # create / update (versioned)
|
|
DELETE /v1/flags/defs/{key} # delete
|
|
GET /v1/flags/activity # the audit log of definition changes</code></pre>
|
|
<p>Every mutation to a flag definition is recorded append-only with the acting user, timestamp and version (<code>apps/flags/store.go</code>), readable at <code>GET /v1/flags/activity</code> — which is what answers "who changed the model rollout percentage at 3am?". The platform's own operational switches are the one cross-tenant surface: they live in the reserved platform store and only a SuperAdmin writes them (<code>apps/flags/flags.go:21-27</code>).</p>
|
|
<h2>The plane that composes this one</h2>
|
|
<p>An A/B test is a caller of this primitive, not a second engine inside it: the experiment registry, the analysis over its arms and the decision that locks a winner are the <code>experiment</code> capability, HIP-1311. Create and decide there write a flag definition here, which is why the arm a request is served and the arm a report names are one value.</p>
|
|
<h3>Integration with the serving path</h3>
|
|
<p>Traffic splitting at the infrastructure layer — the gateway evaluating a flag before the request reaches application code — is a design this section used to specify in KrakenD configuration. No such gateway plugin ships; what ships is in-process composition: any subsystem in the binary evaluates through <code>flags.Assign</code> (the same deterministic rollout hash the HTTP surface uses), which is how <code>apps/experiment</code> and <code>apps/campaign</code> split traffic today with no network hop at all. A gateway-level split remains open design and MUST, if built, evaluate through the same embedded engine rather than a second one.</p>
|
|
<h2>Architecture</h2>
|
|
<p>One binary, one subsystem, no tiers. <code>apps/flags</code> holds the definitions in each org's own encrypted SQLite file and evaluates them in-process through the embedded evaluator. There is no standalone flags service, no SQL-to-KV sync, no KV pub/sub channel, no Kafka exposure topic and no separate deployment — the earlier revision of this HIP specified all four, and the shipped shape replaced them with something strictly simpler: the store is beside the evaluator, so there is nothing to sync and nothing to go stale. Deployment is the cloud image; the plugin binary is <code>plugin/flags</code>.</p>
|
|
<p>The credential is the caller's ordinary org key (HIP-0026). There is no <code>hf_*</code> key family: the evaluate routes take the same bearer as every other <code>/v1</code> surface, and tenancy is the validated principal, never the key prefix.</p>
|
|
<h3>SDK Usage</h3>
|
|
<p>The client surface is the generated cloud SDKs and the <code>hanzo</code> CLI, both projections of the served document (HIP-1030): the flags operations appear as the <code>Flags</code> class/command group in every generated language. The hand-written <code>@hanzoai/flags-js</code> / <code>hanzoai-flags</code> / <code>flags-go</code> packages and the OpenFeature provider wrappers this section used to show are not published; if OpenFeature adapters are wanted they wrap the generated client, they do not replace it.</p>
|
|
<h2>Security</h2>
|
|
<h3>Authentication</h3>
|
|
<p>Every request carries the org's ordinary credential (HIP-0026); there is no flags-specific key family. Tenancy is the VALIDATED principal — <code>principal.Org</code> and <code>principal.Project</code> — never a header a client can write.</p>
|
|
<h3>Flag Access Control</h3>
|
|
<p>Flags are scoped to (org, project), and the isolation is physical, not a filter: each (org, project) pair is its own SQLite file (<code>apps/flags/store.go:3-6</code>), so one tenant's evaluation cannot read another's definitions even in the presence of a query defect. The platform-switch store is the reserved platform namespace and only a SuperAdmin writes it.</p>
|
|
<p>What an attacker gets from the wrong implementation: flags are the policy primitive other planes compose (admission, stage gating per HIP-0139 §8.2), so a cross-tenant write here is not a cosmetic defect — it is another org's kill switches flipped, and a readable beta-flag roster is an existence oracle for capabilities a customer has not been shown.</p>
|
|
<h3>Audit Trail</h3>
|
|
<p>Every flag mutation (create, update, toggle, delete) is recorded with:</p>
|
|
<ul><li>Acting user (from IAM token or API key)</li><li>Timestamp (UTC, millisecond precision)</li><li>Full diff of the change (before/after JSON)</li><li>IP address and user agent</li></ul>
|
|
<p>The audit log is append-only and cannot be modified or deleted via the API. It is stored in SQL with a 2-year retention policy.</p>
|
|
<h2>Monitoring</h2>
|
|
<p>It exports no metrics of its own today: there is no <code>flags_*</code> metric family and no sync or consumer lag to alert on, because there is no sync and no consumer. What a customer can read back under <code>/v1/o11y</code> is the request span every route already gets; the definition change history is <code>GET /v1/flags/activity</code>. Alerting on evaluation latency, if wanted, rides the fleet's ordinary request telemetry rather than a capability-local exporter.</p>
|
|
<h2>References</h2>
|
|
<ol><li><a href="./hip-0004-llm-gateway-unified-ai-provider-interface.md">HIP-4: LLM Gateway</a></li><li><a href="./hip-1190-event-product-analytics.md">HIP-1190: Event — The Product Analytics Plane</a></li><li><a href="./hip-0519-one-identity-boundary.md">HIP-519: One Identity Boundary</a></li><li><a href="https://openfeature.dev/specification/">OpenFeature Specification</a></li><li><a href="https://github.com/open-feature/go-sdk">OpenFeature Go SDK</a></li><li><a href="https://arxiv.org/abs/1707.02038">Thompson Sampling for Multi-Armed Bandits</a></li><li><a href="https://github.com/hanzoai/flags">Hanzo Flags Repository</a></li><li><a href="./hip-1311-experiment-the-ab-plane.md">HIP-1311: Experiment — Arms, Assignment, a Verdict</a></li></ol>
|
|
<h2>Copyright</h2>
|
|
<p>Copyright and related rights waived via <a href="https://creativecommons.org/publicdomain/zero/1.0/">CC0</a>.</p>
|
|
<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-0063.md">This page as plain text</a> · <a href="/llms.txt">Index for agents</a></div>
|
|
</footer>
|
|
</div></body></html> |