AI Prompt — Prompt Registry
- Area: Intelligence
- Path:
services/ai/prompt - Kind: Versioned prompt-template registry (CRUD + render + A/B + ratings)
- Status: v0.1.0 — foundation shipped (2026-05-24); ICU MessageFormat + Mustache renderers, system-tenant ACL, Bearer auth, Go SDK. #010 (2026-05-28, /k-go drain) completed the full ICU spec:
selectordinal, number formatters (integerdecimalpercentcurrency with locale-aware separators + symbols), datetime formatters (shortmediumlongfull), the#placeholder, and per-renderlocaleoverride + serverDefaultLocale— all pure-Go in `internalrender, 11 new tests, v0 forms back-compat. **#009 (2026-05-28) shipped A/B experiment value**: deterministic weighted assignment (AssignVariant, FNV hash ofuser|exp),POST …experiments{id}assign, render-by-experiment_id(resolves variant inline + surfaces it), and the rating back-channel (POST …experiments{id}rating→ per-variant count/mean aggregate); trace-span correlation stays withservicesaitrace#004. **#008 (2026-06-02) shipped Koder ID JWKS auth**: the middleware now validates bearer access tokens via the sharedenginessdkgoauth.JWKSValidator` (the same SDK cachememorycanvassandbox use — reuse-first, no per-service JWT-validation fork), mappingtenant_id→TenantID and aprompt:admin/adminscope→Admin; static-key path kept for service-to-service;[auth.jwks] { jwks_url, issuer, audience }config +Middleware.WithJWKS. Remaining laptop-clean pending: #007 (OpenAPI emission), #011 (licitação seed templates, P1); #006 (kdb-doc storage) is build-tagged.
Role in the stack
prompt is the shared home for every prompt in every Koder product. Today every product inlines its prompts in code — iterating means a code change → release → deploy. There is zero A/B testing, zero version history, zero auditing of "what prompt did we ship last week", and zero reuse across products.
It is the Koder analog of LangSmith, PromptLayer, the Anthropic Prompt Library and Humanloop — built thin on kdb-doc storage with aggressive in-memory caching for the hot read path.
Stable slugs + version pinning + A/B variants + ratings linked to runtime traces = data-driven prompt iteration.
Boundary vs neighbors
services/ai/playgroundis the editing UI (prompt sector ships SDK + REST + thin CLI only).services/ai/evalreads prompts to score variants and writes ratings back.services/ai/tracecorrelates runtime spans to prompt slug+version (links experiments to outcomes).services/ai/gatewaymay render server-side before LLM call (optional fast path).
Features (v1 target)
- Slugged, namespaced, version-pinned prompt registry
- ICU MessageFormat templating (consistent with KoderL10n) + Mustache strict-mode fallback
- A/B experiments with deterministic variant routing
- Ratings (manual + auto from eval) aggregated per variant
- Trace correlation: every render returns slug+version+experiment_id
- System tenant for ship-with-product prompts; tenant-private prompts isolated by default
Primary couplings
| Consumer | Relationship |
|---|---|
services/ai/kode |
All system prompts |
services/ai/agents |
Plan + tool-call prompts per role |
services/ai/extract |
Extraction templates per entity type |
services/ai/classify |
Zero-shot classification templates |
services/ai/translate |
Translation system prompts per language pair |
services/ai/playground |
Editing UI surface |
services/ai/eval |
Reads + writes ratings |
services/ai/trace |
Runtime span linking |
services/ai/gateway |
Optional server-side render |
infra/data/kdb-doc |
Backing store |
RFC and bootstrap
- RFC:
prompt-RFC-001-foundations.kmd— accepted 2026-05-09 - Bootstrap ticket:
services/ai/backlog/done/124-prompt-bootstrap.md - Implementation tickets:
services/ai/prompt/backlog/pending/{001..005}
Self-hosted-first analysis (5 gates)
| Gate | Status | Notes |
|---|---|---|
| G1 Feature parity | pending | Skeleton phase; matches LangSmith / PromptLayer essentials |
| G2 Performance | pending | Target cached fetch p50 < 1ms; 5k req/s sustained per instance |
| G3 Stability | pending | Pre-MVP |
| G4 Capability | pending | Editing UI deferred to playground sector |
| G5 Critical-path readiness | pending | Pre-MVP; consolidating cross-product prompts is the first concrete unblock |