Skip to content

feat(contracts): introduce proto contracts tree and wire.v1 envelope#287

Draft
keugenek wants to merge 1 commit intodatabricks:mainfrom
keugenek:ekniazev/contracts-intro
Draft

feat(contracts): introduce proto contracts tree and wire.v1 envelope#287
keugenek wants to merge 1 commit intodatabricks:mainfrom
keugenek:ekniazev/contracts-intro

Conversation

@keugenek
Copy link
Copy Markdown
Contributor

Summary

Adds contracts/ at the repo root as the source of truth for cross-component
interface shapes described in the design doc.
This PR ships the first slice (appkit/v1/wire.proto) and the build wiring
needed for subsequent contracts to land without further monorepo changes.

What's included

  • contracts/buf.yaml + contracts/buf.gen.yaml — buf module config and codegen
    pipeline using @bufbuild/protoc-gen-es (local, no remote plugin resolution).
  • contracts/appkit/v1/wire.protoSseEnvelope, SseError, ResultFormat enum.
    Covers the SSE envelope, structured error frames, and SQL warehouse
    result-format negotiation. Route conventions, heartbeat/reconnect semantics,
    and the window.__appkit__ client-config payload are deferred to follow-ups.
  • packages/contracts/ — new workspace package @databricks/appkit-contracts.
    Runs buf generate via tools/generate-contracts.ts and re-exports the
    typed bindings. Built with tsdown; follows existing packages/shared/
    conventions.
  • packages/appkit/src/stream/types.ts — imports the generated SseEnvelope
    and adds a compile-time compatibility anchor against the existing
    BufferedEvent. Non-breaking; BufferedEvent will retire in favour of the
    generated type in a follow-up.
  • Root package.jsoncontracts:generate and contracts:lint scripts.
  • docs/docs/contracts.md — short intro page linking back to the design doc
    and outlining the four planned follow-up contracts.

Interface design

Per the design doc, the contracts tree will cover five interfaces:

Contract Status Replaces
appkit/v1/wire.proto this PR hand-maintained SSE types in packages/appkit/src/stream/types.ts
appkit/v1/query.proto follow-up TS-only QueryRegistry augmentation from the type-generator
appkit/v1/plugin.proto follow-up packages/shared/src/schemas/plugin-manifest.schema.json
agenteval/v1/*.proto follow-up ad-hoc JSON between eval framework and apps
appkit/v1/deploy.proto follow-up implicit app.yaml contract with `databricks apps deploy`

Consumers: the TS backend, future Python/Rust ports, the React SDK, the
`databricks` CLI, Claude Code scaffolding skills, and the agent-eval framework
all compile against the same generated bindings.

Verification

  • `pnpm contracts:lint` — buf lint clean.
  • `pnpm contracts:generate` — produces `packages/contracts/src/generated/appkit/v1/wire_pb.ts`.
  • `pnpm -r typecheck` — all 8 workspace projects pass.
  • `pnpm build` — full monorepo build, `@databricks/appkit-contracts` emits dist/, publint clean.
  • `pnpm test` — 1564 tests pass (no new or changed tests in this PR).
  • `pnpm knip` + `pnpm check` — clean.

Test plan

  • Regenerate locally: `pnpm contracts:generate` and verify `packages/contracts/src/generated/appkit/v1/wire_pb.ts` is produced deterministically.
  • Intentionally break the contract (e.g. rename `SseEnvelope.id` to `eventId` in the proto, regenerate) and confirm `pnpm -r typecheck` fails on the `_BufferedEventSseEnvelopeCompat` anchor.
  • Confirm `pnpm build` produces `packages/contracts/dist/` with `.d.ts` + `.js` for the generated types.

Follow-ups

See design doc for the full five-contract plan. Next PRs:

  1. `appkit/v1/query.proto` — retires the TS-only `QueryRegistry` augmentation.
  2. `appkit/v1/plugin.proto` — retires `plugin-manifest.schema.json`.
  3. `agenteval/v1/*.proto` — lands alongside the eval-framework work.
  4. `appkit/v1/deploy.proto` — coordinates with the `databricks` CLI team.

This pull request and its description are AI-assisted by Isaac.

Adds `contracts/` at the repo root as the source of truth for the cross-component
interface shapes described in the design doc. This PR ships the first slice
(`appkit/v1/wire.proto`) and the build wiring needed for subsequent contracts to
land without further monorepo changes.

What's included
- `contracts/buf.yaml` + `contracts/buf.gen.yaml` — buf module config and codegen
  pipeline using @bufbuild/protoc-gen-es (local, no remote plugin resolution).
- `contracts/appkit/v1/wire.proto` — SseEnvelope, SseError, ResultFormat enum.
  Covers the SSE envelope, structured error frames, and SQL warehouse
  result-format negotiation. Route conventions, heartbeat/reconnect, and the
  `window.__appkit__` client-config payload are deferred to follow-up PRs.
- `packages/contracts/` — new workspace package `@databricks/appkit-contracts`.
  Runs `buf generate` via `tools/generate-contracts.ts` and re-exports the
  typed bindings. Built with tsdown, follows existing `packages/shared/`
  conventions.
- `packages/appkit/src/stream/types.ts` — imports the generated `SseEnvelope`
  and adds a compile-time compatibility anchor against the existing
  `BufferedEvent` shape. Non-breaking; `BufferedEvent` will retire in favour
  of the generated type in a follow-up.
- Root `package.json` — `contracts:generate` and `contracts:lint` scripts.
- `docs/docs/contracts.md` — short intro page linking back to the design doc
  and outlining the four planned follow-up contracts.

Follow-ups tracked by the design doc
- `appkit/v1/query.proto` — typed SQL query schemas (replaces the TS-only
  `QueryRegistry` augmentation).
- `appkit/v1/plugin.proto` — plugin manifest (replaces the JSON Schema in
  `packages/shared/src/schemas/plugin-manifest.schema.json`).
- `agenteval/v1/*.proto` — versioned eval framework to app protocol.
- `appkit/v1/deploy.proto` — app manifest consumed by `databricks apps deploy`.

Verification
- `pnpm contracts:lint` — clean.
- `pnpm contracts:generate` — produces `packages/contracts/src/generated/appkit/v1/wire_pb.ts`.
- `pnpm -r typecheck` — all 8 workspace projects pass.
- `pnpm build` — full monorepo build succeeds, `@databricks/appkit-contracts`
  emits dist/ via tsdown, publint clean.
- `pnpm test` — 1564 tests pass (no new or changed tests in this PR).

This PR and its description are AI-assisted by Isaac.

Signed-off-by: Evgenii Kniazev <evgenii.kniazev@databricks.com>
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.

1 participant