Skip to content

RFC: standardize the HSM API surface (v1) — treat it as a product #146

Description

@juniperbevensee

Spawned from the credential-request-link discussion (2026-07-03): agents now compose HSM URLs/API calls (/keys?request=&assign=), other tools script against /api/keys and /api/harnesses, and the BYO-credentials epic will add broker endpoints consumed by every gateway. The API is becoming a contract; today it's an accretion.

Current state (observed)

  • Routes are unversioned (/api/keys, /api/harnesses, /api/settings, /api/people, /api/surfaces, …)
  • Auth model is good but implicit: GETs ungated, mutations require the hsm_session cookie (operator token HMAC). Nothing documents which routes exist or their shapes except the source.
  • No error envelope convention ({error} vs bare 404 HTML vs NextResponse defaults)
  • Naming drift: agents are "harnesses" in the API (h_* ids), "agents" everywhere in conversation; there is no /api/agents (a natural first guess — it 404s)
  • No machine-readable schema; consumers (agents, scripts, future broker clients) reverse-engineer from lib/services/*

Proposal

  1. /api/v1 prefix with the current surface frozen as v1; old paths alias during a deprecation window
  2. OpenAPI spec generated from source (route handlers + zod schemas), served at /api/v1/openapi.json; becomes the doc of record
  3. Uniform error envelope: { error: string, code?: string } + correct content-type on all API 4xx/5xx (no HTML 404s under /api)
  4. Explicit auth policy doc: ungated-GET / cookie-gated-mutation as a stated invariant, plus a second credential class (scoped automation tokens) for non-browser callers — needed before the credential broker lands
  5. Naming decision: pick harnesses or agents once, alias the other
  6. First standardized flow: the credential-request pattern (/keys?request=&assign=) documented as the canonical "intent link" idiom — GET encodes intent, never state change

Non-goals

Public internet exposure. This stays a tailnet-plane API; standardization is about contract quality, not reach.

Related: BYO-credentials epic (nimbleco-memory specs/2026-07-03-byo-user-credentials-epic.md) — broker endpoints should land on this surface, not beside it.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions