Skip to content

API v2 Phase 2: Huma contract foundation #882

Open

Description

@Quick104

Part of the API v2 program epic #135. Durable architecture: docs/architecture/api-contract.md (PR #880).

Scope (program Phase 2 — contract foundation, a small number of focused PRs, not the first domain migration):

  • Pin Huma v2 + humachi; mount one /api/v2 API inside the existing root chi middleware stack; no global CORS.
  • Deterministic operation registration separated from runtime dependency construction; domain-grouped registration.
  • Encode the ratified shared wire rules with tests: RFC 9457 adapter with stable Silo problem types, success/envelope rules, presence/null semantics, opaque string IDs, RFC 3339 UTC millisecond instants, lowercase enums, repeated-query grammar, sort allowlists, cursor pagination (50 default / 200 max), retry/idempotency classification, opt-in optimistic concurrency, jobs/cancellation, bulk contracts, no-store default, 1 MiB JSON body cap.
  • Explicit framework configuration: RejectUnknownQueryParameters, NoFormatFallback, huma.DefaultArrayNullable = false + non-nil collection builders, structured-body media-type guard (415), named instant transport type, explicit explode metadata, cleared built-in OpenAPI/docs/schema routes and schema-link transformer, and an explicit structured-body read timeout (current 30 s server read timeout is the comparison baseline; Huma's 5 s default is not adopted implicitly — final value is an open execution input on API v2 program epic: /api/v2 contract reset on Huma, bounded bridge, v1 retirement at 1.0 #135).
  • Error adapter + middleware parity tests through public, authenticated, profile-scoped, acting-admin/admin, demo-mode, and rate-limited paths.
  • GET /api/v2/system/info: unauthenticated, body-bounded, cache-controlled, always registered.
  • Deterministic OpenAPI 3.1 artifact under contracts/api/v2/ with byte-diff CI, pinned semantic-diff tool (seeded breaking fixture), OpenAPI lint, served/embedded exact bytes; fixture framework with schema validation and privacy scan; observability labels (API major, operation ID, status class, error code) plus v2 validation-failure and v1-tombstone counters.

Gate: foundation tests pass without external services; the spec is deterministic across clean checkouts; middleware parity proven by probe operations; a Huma-generated validation failure is indistinguishable in envelope quality from an application error; CI fails on stale spec, unaccounted route, duplicate operation ID, invalid fixture, and a seeded breaking change.

AI disclosure: drafted by Claude Code (claude-fable-5) orchestrating the #135 program.

Activity

  1. added
    api-v2
    on Sep 1, 2026
  2. Quick104 commented on Sep 4, 2026

    @Quick104
    ContributorAuthor

    Checkpoint 2026-09-04: PR #936 open for this phase.

    Scope delivered against the list above: listener mounted with no global CORS; deterministic registration separated from wiring; RFC 9457 adapter and the shared wire rules with tests; explicit framework configuration; parity tests through public, authenticated, profile-scoped, acting-admin, demo-mode and rate-limited paths; GET /api/v2/system/info; the OpenAPI 3.1 artifact with byte-diff CI, pinned semantic diff and seeded breaking fixture, spec lint, served and embedded bytes with a digest, route/spec reconciliation, contract fixtures, and operation-labelled observability.

    Gate: foundation tests pass with no external services; the artifact is byte-identical across repeated and clean-checkout generation; parity is proven by probe operations; a Huma validation failure renders through the same Problem Details adapter as an application error; CI fails on a stale spec, an unaccounted route, a duplicate operation ID, an invalid fixture, and a seeded breaking change.

    Still open on this issue (deferred by design, named in the contract's Foundation subsection as "Not yet encoded"): optimistic concurrency (ETag/If-Match/428/412 and RFC parser tests), idempotency classification, the 202 job shape, the bulk contract, and RFC 9745/8594 deprecation headers. Each lands with the first v2 operation that needs it, before the first Phase 3 domain PR.

  3. added
    triaged
    and removed
    triaged
    on Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-v2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions