tmh, the TeachMeHIPAA CLI

SDK design grilling — 2026-11-15

A /grill-with-docs session for the six official TeachMeHIPAA SDK repos. Nick asked for every question to be answered by the agent, so each answer below is the recommended answer, accepted as asked. Every question is worded so “yes” accepts the recommendation.

Inputs: docs/research/ in each repo (Stripe SDK + CLI research) and internal research on the TeachMeHIPAA Developer API as an SDK target (not published). Questions are asked in rounds; a round contains only questions whose prerequisites were settled in an earlier round.

Repos: teachmehipaa-node, teachmehipaa-python, teachmehipaa-ruby, teachmehipaa-dotnet, teachmehipaa-java, teachmehipaa-cli.


Round 1 — scope, generation strategy, posture

❓ Q1 - Which contract: Do the SDKs target only the developer document (/openapi.developer.json, 56 operations), not the full public spec (130 operations, mostly first-party console routes)?

➡️ Yes. The developer document is the partner contract. First-party routes (/me, invitations, SSO, SCIM) are not in it and must not appear in the SDKs.


❓ Q2 - Hand-written core, generated surface: Is each SDK a hand-written core (transport, auth, retries, errors, pagination, webhooks, operations) with a generated resource and model layer, the way Stripe’s SDKs are built?

➡️ Yes. 56 operations and about 60 models in five languages and a CLI would drift if written by hand, and the API is additive-only within /v1, so regeneration is routine. The core is where the behaviour is; it stays hand-written and tested.

Rejected: openapi-generator. The developer spec has colon custom-method paths, oneOf without discriminators, OAS 3.1 null type arrays, binaries without format: binary and status-polymorphic responses. Stock generators mangle all of these and emit non-idiomatic code.


❓ Q3 - Client object only: Do the SDKs ship only an instantiated client (new TeachMeHipaa(...), TeachMeHipaa::Client.new), with no global or static configuration?

➡️ Yes. Stripe is retiring its global style in every language, and new endpoints only reach StripeClient. A global token cache would also be shared across organizations, which breaks multi-org partners.


❓ Q4 - Package names: Are the package names teachmehipaa on npm, PyPI and RubyGems, TeachMeHipaa on NuGet, com.teachmehipaa:teachmehipaa-java on Maven Central, and is the CLI binary tmh?

➡️ Yes. All are unclaimed (checked 2026-11-15). They mirror Stripe’s (stripe everywhere, Stripe.net, com.stripe:stripe-java, binary stripe). tmh is short to type, and the brand name stays in the package names.


❓ Q5 - Versioning: Do SDKs use their own semver, with each SDK major bound to API major /v1, and record the spec release they were generated from in OPENAPI_VERSION?

➡️ Yes. The API has no version header and info.version is a release codename (waggish-wombat), so there is nothing to pin per request. Adding response fields is a minor release, a breaking SDK surface change is a major release.


❓ Q6 - Runtime baselines: Are the baselines Node 20+, Python 3.10+, Ruby 3.2+, .NET net8.0 + netstandard2.0, Java 17 and Go 1.24+ for the CLI?

➡️ Yes. These are the oldest versions still supported upstream as of late

  1. Java 17 brings records and sealed types; Java 11 is out of support outside paid support plans. netstandard2.0 keeps .NET Framework 4.8 shops (common in healthcare) on board.

❓ Q7 - Release posture: Do we build CI and release workflows now, but publish nothing to any registry until Nick says the API is live?

➡️ Yes. The developer API ships dark, and Nick said on 2026-11-13 “I do not want this live”. Release workflows exist but only run on a manual dispatch.


❓ Q8 - License: Are the SDKs MIT-licensed?

➡️ Yes. That matches every Stripe SDK. The repos are private now, but they will go public at launch, and partners vendor SDK code.


❓ Q9 - Telemetry and logging stance: Do the SDKs send only a User-Agent (SDK name/version, language runtime, optional app info), write nothing to disk, never detect AI agents, and keep logging off by default with request and response bodies never logged?

➡️ Yes. This is a HIPAA product. Stripe’s on-disk telemetry IDs, AI-agent detection and debug-level body logging are all skipped (each research doc’s Skip rows). Logs may carry method, path, status, latency and request id; the Authorization header is always redacted.


Round 2 — the shared contract (depends on Q1, Q2, Q3, Q9)

❓ Q10 - One normalized description for all generators: Do all six generators read one normalized SDK description (openapi/sdk-ir.json), produced by a single tool from the developer spec, instead of each generator interpreting raw OpenAPI itself?

➡️ Yes. Naming rules, model renames, union discriminators, open enums, pagination kind, idempotency, binary handling and spec workarounds are decided once. Each generator becomes a thin template over the IR, so the six SDKs stay consistent by construction.


❓ Q11 - Where the IR builder lives: Does the IR builder live in the monorepo at tooling/sdk-ir, next to the Zod registry that generates the spec, with each SDK repo vendoring openapi/openapi.developer.json and openapi/sdk-ir.json?

➡️ Yes. The monorepo owns the contract. Stripe keeps SDK metadata in its spec as x-stripe* extensions; we start with a builder plus override table and can later move the metadata into registry extensions. Vendoring keeps every SDK buildable on its own. A later monorepo workflow can open regeneration PRs in each SDK repo when the spec changes (follow-up, not this pass).


❓ Q12 - Method naming rule: Are SDK names derived as resource.method, with the resource from the tag (pluralized, camelCase) and the method from the operationId verb (list, retrieve for get, create, update, del/delete, or the custom verb), plus a small override table?

➡️ Yes. Examples: cancelEnrollment → enrollments.cancel, upsertLearnerByExternalId → learners.upsertByExternalId, downloadCertificatePdf → certificates.downloadPdf, listPartnerOrganizations → partners.organizations.list. One override comes from the glossary: getCertificateCredentials returns a LinkedIn link and a verification link, and “credential” is banned for completion artifacts, so it becomes certificates.retrieveLinks (its spec summary is “Retrieve certificate links”). Each language applies its own casing (learners.upsert_by_external_id in Python and Ruby, Learners.UpsertByExternalIdAsync in .NET). The table is the method table in the coverage test, which also applies Q25’s splits.


❓ Q13 - Model naming: Do models drop the Dto suffix, and do inline page item schemas resolve to the named model when the shapes are equal?

➡️ Yes. LearnerDto → Learner, CertificatesPage.items → Certificate[], so no CertificatesPageItemsInner types.


❓ Q14 - Auth seam: Is auth a single TokenProvider seam with three adapters: client credentials (the default), a partner grant (refresh token plus a TokenStore), and a static access token?

➡️ Yes. The client constructor takes clientId + clientSecret for the common case and builds the client-credentials provider itself. The provider:

Stripe has no equivalent; the research for every language flags this as the main new design.


❓ Q15 - OAuth helpers: Do the SDKs ship PKCE helpers for partner apps (build the authorize URL with S256 challenge and state, exchange the code), but no web-server integration?

➡️ Yes. The helpers are pure functions plus one token call. Routing the redirect is the partner’s framework’s job.


❓ Q16 - Organization binding: Is the organization a client-level setting, resolved once via GET /auth/introspection when not given, and never a positional parameter on org-scoped methods?

➡️ Yes. A client-credentials or partner-grant token is bound to one organization, and any other orgId returns 403 org_not_active. Making every caller pass orgId would be pure noise. Callers who know it can pass organizationId to skip the introspection call. partners.* methods take partnerId positionally because the partner id is not discoverable.


❓ Q17 - Environments: Is there an environment option (live default, sandbox) that picks the base URL, plus a baseUrl override?

➡️ Yes. Secrets carry no mode prefix (tmh_cs_… in both), so the SDK can’t infer the mode the way Stripe infers it from sk_test_. Defaulting to live is safe: sandbox credentials against live fail with invalid_client.


❓ Q18 - Retries: Do the SDKs retry twice by default, with exponential backoff from 0.5 s to a 5 s cap with jitter, on network errors, 409 conflict, 429 and 5xx, honoring Retry-After (capped at 60 s), and only for requests that are safe to replay?

➡️ Yes. Safe means: GET, any request that carries an Idempotency-Key, and quoteSeatOrder, confirmPaymentMethod and createLearnerLaunchLink, which are idempotent by meaning. PATCH and DELETE are not retried after a response was possibly received. This copies Stripe and fixes its gaps (Stripe ignores Retry-After and doesn’t retry 429).


❓ Q19 - Idempotency keys: Do the SDKs generate a UUIDv4 Idempotency-Key for every operation whose spec marks it required, reuse it across the SDK’s own retries, and let callers override it per request?

➡️ Yes. The key is required on 22 operations and a missing one is a 422. Generating it per call (not per attempt) is what makes the retries safe.


❓ Q20 - Errors: Is the error model a base TeachMeHipaaError with subclasses chosen by HTTP status, each exposing status, an open-string code, title, detail, field errors, requestId, response headers and the raw body?

➡️ Yes. Subclasses: AuthenticationError (401), PermissionError (403), NotFoundError (404), ConflictError (409), PreconditionFailedError (412/428), InvalidRequestError (400/405/406/415/422), IdempotencyError (422 idempotency_key_reuse), RateLimitError (429, with retryAfter), ApiError (5xx and unexpected bodies), OAuthError (the token endpoint’s {error, error_description}), and ConnectionError (no response). A content-type guard turns the API’s 200 text/html for unknown paths into an ApiError instead of a parse crash. Java exceptions are unchecked.


❓ Q21 - Response metadata: Does every returned object expose its response metadata (status, headers, requestId, etag) without making callers unwrap an envelope?

➡️ Yes. Stripe’s lastResponse pattern. Callers get the Learner directly; learner.lastResponse.etag feeds If-Match.


❓ Q22 - Pagination: Do list methods return a page that can also be iterated across all pages, with a separate tail iterator for the events log?

➡️ Yes. {items, nextCursor} drives a Stripe-style auto-pager (for await / generators / Enumerable / IAsyncEnumerable / Iterable). The events log pages with after=evt_… and returns nextCursor: null at the current end, so events.tail() keeps its own last-seen event id.


❓ Q23 - Webhook verification: Do the SDKs ship webhooks.constructEvent(rawBody, headers, secret, path) that verifies the x-tmh-signature HMAC over POST\n<path+query>\n<timestamp>\n<sha256(body)> with the secret’s UTF-8 bytes as key, rejects timestamps more than 5 minutes off in either direction, compares in constant time, and returns either an Event or a TestDelivery?

➡️ Yes. The signed string includes the endpoint path, so the verifier needs the path the request arrived on. :test deliveries are not event envelopes (body {subscriptionId, test: true}, UUID event id), so they get their own type rather than failing strict parsing. A generateTestHeaders helper signs payloads for partners’ own tests. Unknown event types parse as a generic event instead of failing, because the catalog is additive-only.


❓ Q24 - Long-running operations: Is there an Operation type with a wait() helper that polls getOperation with backoff until done or a timeout, plus typed accessors for the export CSV?

➡️ Yes. Most operations finish inline (done: true), so wait() returns immediately for them. :test and :redrive are the ones that stay pending.


❓ Q25 - Status-polymorphic responses: Where the response schema depends on the request, is the operation split into separate methods, and where it depends on server state, is a tagged result returned?

➡️ Yes. importEnrollments becomes enrollments.previewImport (validateOnly: true → ImportPreview) and enrollments.import (commit → Operation). batchEnrollments by explicit ids vs by filter becomes enrollments.batch and enrollments.batchByFilter. createLearner and upsertLearnerByExternalId return a LearnerWriteResult: the Learner, a created flag (201 vs 200), and the 201-only delivery and joinUrl (absent on 200). createSeatOrder returns SeatOrderCreated for both 201 and 202 (the spec uses one schema for both).


❓ Q26 - Binary and multipart: Does certificates.downloadPdf return a binary response (bytes or stream plus content type and filename), and does enrollments.import accept a path, bytes or a stream for the CSV?

➡️ Yes. The core handles both; the IR marks the operations, because the spec lacks format: binary.


❓ Q27 - Unknown fields and enums: Do models ignore unknown fields but keep them accessible, and are enums open (known constants plus any string)?

➡️ Yes. 27 of 39 response schemas are strict in the spec, but /v1 is additive-only, so a strict client would break on every new field. code, event types, audit types and seat-order statuses all grow.


❓ Q28 - PATCH semantics: Do PATCH methods send application/merge-patch+json and distinguish “leave unchanged” from “set to null” in each language’s idiom?

➡️ Yes. Node: undefined vs null. Python: a NOT_GIVEN sentinel. Ruby: key absent vs nil. .NET: an Optional<T>. Java: builder clearX() sets null explicitly. The server returns 415 for application/json.


❓ Q29 - Testing strategy: Is each SDK tested at three levels: core unit tests through an injected fake HTTP transport, generated-surface tests that assert every operation in the vendored spec maps to exactly one method, and a contract suite against a Prism mock of the vendored spec, with an optional sandbox suite that only runs when credentials are present?

➡️ Yes. The transport is the one real seam: it has two adapters, the real HTTP client and the test fake. CI never calls the live API.


Round 3 — per-language idiom (depends on Q2, Q6, Q10, Q14, Q20, Q28)

❓ Q30 - Node: Is teachmehipaa-node written in TypeScript, shipped as ESM + CJS, zero runtime dependencies (global fetch, crypto.subtle/ node:crypto), server-only, with new TeachMeHipaa({ clientId, clientSecret }) as the entry point?

➡️ Yes. Node 20 has fetch. CORS never allows partner origins, so the browser is not a target. Bun and Deno work through the same fetch.


❓ Q31 - Python: Is teachmehipaa-python built on httpx with two client classes, TeachMeHipaa and AsyncTeachMeHipaa, sharing pure request-building code, with pydantic v2 response models and TypedDict params?

➡️ Yes. One HTTP library instead of Stripe’s six-library fallback, and two classes instead of *_async twins on every method. Pydantic gives tolerant parsing (extra="allow") and real types.


❓ Q32 - Ruby: Is teachmehipaa-ruby zero-dependency on net/http, with TeachMeHipaa::Client.new(client_id:, client_secret:), generated model classes on a small TeachMeHipaa::Model base (typed readers, to_h, [] for unknown keys), RBS signatures, and a Mutex-guarded token cache?

➡️ Yes. Stripe’s dynamic StripeObject hides the schema; generated readers plus RBS give editors real types. Everything is configured per client and frozen, which fixes Stripe’s global-only timeouts and retries.


❓ Q33 - .NET: Does teachmehipaa-dotnet target net8.0;netstandard2.0, use System.Text.Json with source generation, expose async-only methods with a CancellationToken, use *CreateOptions-style parameter classes, run auth and retries as DelegatingHandlers, and ship an AddTeachMeHipaa() DI extension for IHttpClientFactory?

➡️ Yes. Stripe moved to System.Text.Json in v51 and keeps Newtonsoft only for backward compatibility. Sync-over-async wrappers cause deadlocks, so no sync methods. Nullable reference types are on. The DI extension ships in the same package to keep one install.


❓ Q34 - Java: Does teachmehipaa-java use Java 17, java.net.http, Jackson, TeachMeHipaaClient.builder(), *CreateParams.builder() params, immutable model classes with getters, unchecked exceptions, and a ReentrantLock single-flight token cache?

➡️ Yes. java.net.http removes the OkHttp dependency and supports PATCH, which Stripe’s HttpURLConnection enum lacks. Jackson is the enterprise default and handles @JsonAnySetter for unknown fields. Checked exceptions fight iterators, so they’re unchecked, as in Stripe’s own pagination wrappers.


❓ Q35 - CLI: Is teachmehipaa-cli a Go binary (tmh) built with cobra, with resource commands generated from the IR (tmh learners list, tmh enrollments cancel <id>), credentials in the OS keyring with a 0600 file fallback, sandbox and live profiles, and GoReleaser for distribution?

➡️ Yes. A single static binary is what Homebrew, Scoop and Docker want, and GoReleaser config carries over from Stripe almost unchanged. A Bun-compiled binary would be 60–100 MB with weaker keyring support. The CLI talks HTTP directly; it does not wrap another SDK, just as the Stripe CLI doesn’t use stripe-go.


❓ Q36 - CLI login and listen: Does tmh login store API-client credentials per profile (with partner PKCE login via a loopback redirect as a later addition), and does tmh events tail --forward-to <url> replace Stripe’s listen by polling the events log and re-signing each event locally with a per-profile secret?

➡️ Yes. We have no relay service like Stripe’s websocket. Our signature covers the endpoint path, so the CLI computes it per --forward-to URL, and prints the local signing secret so partners can verify forwarded events with their own SDK’s constructEvent. Errors parse problem+json and exit non-zero with distinct codes. --all auto-paginates; --wait waits on operations. Telemetry is off.


Round 4 — upstream spec gaps (depends on Q10, Q11)

❓ Q37 - Work around, then fix upstream: Does the IR builder work around the developer spec’s gaps (binary formats, missing discriminators, inline page items, the undeclared ETag on getLearner, the empty webhooks section, the missing event envelope), and do we file one monorepo issue listing the upstream fixes?

➡️ Yes. The SDKs shouldn’t wait on spec changes, but each workaround is a debt with an owner. The issue lists: format: binary, discriminators, $ref page items, declared x-request-id/RateLimit-*/ETag headers, the exported webhook envelope, /auth/token security: [], a refresh-token reuse grace window, live/test secret prefixes, and webhook secret rotation.


❓ Q38 - Done means: Is a repo done for this pass when its generated surface covers all 56 operations, the core passes its unit and contract tests, CI is green on GitHub, and the README shows a working quickstart, with no registry publish?

➡️ Yes.


Frontier empty: every branch has been visited. Decisions that are hard to reverse, surprising, and the result of a real trade-off are recorded as ADRs in docs/adr/.


Amendments after implementation and code review (2026-11-15)

These decisions came up while building and reviewing the six SDKs. Each refines or overrides an answer above; the code follows them.