Skip to content

docs: ADR 0253 — SDK mocking testkit - #875

Merged
kantord merged 2 commits into
mainfrom
add-mocking-testkit-adr
Aug 31, 2026
Merged

kantord merged 2 commits into
mainfrom
add-mocking-testkit-adr

Conversation

@kantord

@kantord kantord commented Aug 31, 2026

Copy link
Copy Markdown
Member

What

The decision record for issue #872's mocking testkit. Docs only — no production code.

Adds ADR 0253 and its index entry.

Why

Neither #761 nor #821 describes a client-side SDK mocking story — only a real mecated --mock daemon, useful for the SDK's own test suite but not for a downstream app's unit/e2e tests. #872 tracks closing that gap; this ADR is the decision record for how.

What was actually surveyed (checked directly, not assumed)

  • stacklok/toolhive-studio / stacklok/toolhive-cloud-ui (public, Apache-2.0): mature MSW/OpenAPI auto-mocker, zero Connect-RPC/gRPC support.
  • stacklok/frontend-platform's @stacklok/mocks (public, Apache-2.0, real npm package): extracts that same REST auto-mocker per its own ADR 0014. Its AutoAPIMock<T> core is schema-agnostic; its buildServerHandlers()/codegen half is OpenAPI-route-shaped and doesn't fit Connect-RPC at all.
  • A private, unmerged prototype (a sibling internal repo exploring Connect-RPC mocking for a different product) already has a working unary buildGrpcServerHandlers() + grpcResponse() — walks a real GrpcServiceDescriptor, validates request bytes against the protobuf schema, resolves a hand-authored fixture, encodes a real protobuf-binary response. Its own thrown error is explicit: "streaming gRPC methods aren't supported by the automocker yet."

The decision

  1. Vendor, don't depend. Copy and adapt the AutoAPIMock core + the unary buildGrpcServerHandlers/grpcResponse pattern into sdk/typescript/, reconfigured for mecatl's actual services. No npm dependency on @stacklok/mocks in this iteration — the code becomes mecatl's own.
  2. Correct SPDX headers on port — the source carries Proprietary; mecatl is Apache-2.0. Same fix class PR feat(studio): Web UI workspace #618's vendor-drop already established.
  3. Streaming/bidi mocking is an explicit, named residual — Converse (bidi) and any future WatchSessionEvents, plus modeling run_id/expected_run_id race semantics (the state needed to reproduce the stale-control bug PR feat(engine,server): durable run identity — a host-minted run_id #827/feat(server): expected_run_id on controls, and strict steer #828 fixed), are unsolved anywhere surveyed, not just here. Named honestly rather than silently dropped, mirroring ADR 0250's own residual-disclosure discipline.
  4. Lives inside mecatl's own SDK tree for now — no separate shared package. A follow-up issue will track proper ecosystem-wide "slot-in" operationalizing once a second real Connect-RPC consumer needs it.

Verification

  • go test ./docs/lint/... — green.
  • No production code, so task test is unaffected.

Refs #872.


Fully or partially written by an AI agent.

@kantord
kantord marked this pull request as ready for review August 31, 2026 13:48

@samuv samuv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed against the code on main (a1f987db) and against the sources the ADR cites. The survey discipline is the best part of this — "checked directly rather than assumed" is accurate, and I verified the #618 precedent does substantively say what the ADR claims. Decision 4's refusal to build a shared package before a second consumer exists is well-argued and matches the repo's stated anti-premature-abstraction posture.

Four findings, one of which I think inverts the cost/benefit of the central decision.

Findings, severity order

  1. L70 — the day-one coverage claim is a transport category error. The vendored artifact is a Connect-RPC/gRPC automocker that validates protobuf request bytes and encodes protobuf responses. The four endpoints it claims to cover "over HTTP" are hand-written JSON on that transport (approveBody, cancelBody, GET /v1/compatibility). This matters beyond pedantry: the licensing-sensitive vendoring buys coverage for the transport #821 says browsers never speak, while the coverage actually claimed belongs to the already-Apache-2.0 REST mocker.
  2. L5 — the Scope names a tree that does not exist, and no gate would cover it. No sdk/, no root package.json/tsconfig.json, and no TypeScript CI job on main.
  3. L57-62 — the #618 precedent is real but is cited in the wrong tense, and its enforcement mechanism (a CI guard) is the part worth adopting.
  4. L97 — the confidentiality/provenance assertion is the one claim in the ADR that can't be checked from this repo, and it is carrying the licensing decision.

Plus a mechanical note on the README line: this collides with #874 by construction.

None of this disputes the shape of the decision — vendor the unary pattern, defer streaming, don't build a shared package yet. Finding 1 is the one I'd want resolved before this becomes the spec for #872, because it changes which code needs vendoring and therefore how much licensing surface the decision actually touches.

Comment thread docs/adr/0253-sdk-mocking-testkit.md Resolved
Comment thread docs/adr/0253-sdk-mocking-testkit.md Resolved
Comment thread docs/adr/0253-sdk-mocking-testkit.md Resolved
Comment thread docs/adr/0253-sdk-mocking-testkit.md Resolved
Comment thread docs/adr/README.md Resolved
kantord and others added 2 commits August 31, 2026 17:29
Vendor (not npm-depend on) the proven unary Connect-RPC handler
pattern + AutoAPIMock core; defer streaming/bidi mocking (Converse,
the stale-run-control race) as a named residual. Lives inside
mecatl's own SDK tree for now, no shared package yet.

Docs only; implementation tracked separately.

Refs #872.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Per samuv's review: fix the "over HTTP" transport category error
(the vendored automocker covers unary gRPC, not the hand-written
JSON HTTP endpoints), name the sdk/typescript/ ordering dependency
on #821 and the missing TS CI gate, correct #618's tense (open, not
merged) and adopt its SPDX-guard pattern scoped to sdk/, and record
the header rewrite as an authorized relicense (Stacklok holds
copyright on both sides) rather than a bare header edit.

Also reframes scope explicitly: the SDK's own testability (near-term
deadline) and Studio's eventual HTTP/JSON mocking needs (later,
architecture undecided) are separate, coexisting concerns. This ADR
only needs to unblock the former.

Rebased onto main (#874 merged) and regenerated llms.txt.

Fully or partially written by an AI agent.

Co-Authored-By: Claude <[email protected]>
@kantord
kantord force-pushed the add-mocking-testkit-adr branch from ba3e96e to ad8993e Compare August 31, 2026 15:30
@kantord
kantord merged commit 0f31e2f into main Aug 31, 2026
22 checks passed
@kantord
kantord deleted the add-mocking-testkit-adr branch August 31, 2026 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants