Framework Surface
1. Purpose
Boundra should not stop at being a boundary checker. The next layer is a small TypeScript-facing framework surface that lets real applications use Boundra-generated contracts without replacing Next.js, bundlers, ORMs, UI frameworks, or test runners.
This document defines the language split for the next phase.
2. Language Responsibilities
Rust Engine
Rust remains responsible for deterministic tooling:
- project and domain manifest loading
- import scanning and boundary analysis
- rule diagnostics
- dependency graph generation
- CLI orchestration
- code generation file writes
Rust should stay strict, fast, and boring.
TypeScript Surface
TypeScript should own the application-facing API:
- generated contract types
- route/query/mutation adapters
- client/server helper functions
- framework integration helpers for apps
- framework-neutral developer diagnostic rendering
- developer-facing package entrypoints
TypeScript is the right layer for anything application code imports directly.
Extension DSL
An extension DSL may be introduced later, but it should not come before real dogfooding.
Preferred order:
- TypeScript framework surface
- schema-backed codegen templates
- dogfood project feedback
- Starlark policy/codegen hooks
- optional Lua local automation hooks
3. Starlark vs Lua Decision
Boundra should prefer Starlark over Lua for core extensibility.
Reasons:
- Starlark is deterministic and policy-oriented.
- It fits rule/config/codegen customization better than unrestricted scripting.
- It aligns with Boundra's "safe constraints over freedom" principle.
- It avoids turning project policy into arbitrary local scripts too early.
Lua remains a possible later option for local automation or AI/MCP scripting, but not for core policy.
4. First TypeScript Package
The first TypeScript-facing package should be intentionally small.
Candidate package:
packages/
runtime/
src/
types.ts
index.ts
Initial responsibilities:
- expose schema-backed helper types for generated contracts
- define route/query/mutation contract and implementation shapes
- validate contract input and result values
- provide a framework-neutral client/transport boundary
- avoid framework-specific runtime behavior
- avoid depending on React, Next.js, database clients, or server runtimes
The browser error view follows the same rule: packages/ui owns DOM rendering,
while Vite and host applications own error capture and lifecycle integration.
It is distributed as boundra/ui rather than a second npm package.
Non-goals:
- no HTTP server
- no router replacement
- no built-in fetch transport yet
- no React hooks runtime yet
- no ORM integration
5. Generated Code Direction
Generated files use runtime-backed schema shapes.
Example direction:
import { defineRoute, type InferSchema } from "boundra";
import { z } from "zod";
export const createInvoiceInputSchema = z.object({});
export const createInvoiceResultSchema = z.object({});
export type CreateInvoiceInput = InferSchema<typeof createInvoiceInputSchema>;
export type CreateInvoiceResult = InferSchema<typeof createInvoiceResultSchema>;
export const createInvoiceRoute = defineRoute({
name: "create-invoice",
input: createInvoiceInputSchema,
result: createInvoiceResultSchema,
});
Zod authors schemas, while the runtime depends only on a structural parse
contract. See docs/contract-schema-spec.md and ADR 0002.
6. Dogfooding Rule
Do not add Starlark, Lua, or WASM plugin runtime until Boundra has been used in at least one real internal project flow.
The first validation target is complete:
- create at least two domains
- generate at least one route, query, and mutation
- wire generated contracts into an app package or app folder
- run
check-boundariesandgraph-domainsduring normal development - record missing APIs before adding extension scripting
The committed examples/order-billing flow now covers these points and is
verified by pnpm verify-example. It exposed placeholder contract types, manual dependency
declarations, and missing public export generation as the next design inputs.
Those inputs are resolved by ADR 0002, schema-backed generated contracts, the
framework-neutral client/server runtime, add-dependency, and generated shared
public exports.
7. First Implementation Slice
Status: complete.
The first code slice was:
- add
packages/runtime - define pure TypeScript helper types
- update generated route/query/mutation templates to import those helper types
- add a small fixture test that verifies generated files use the runtime surface
This keeps the next step practical without prematurely adding a plugin language.