Skip to content

Commit 238e7a6

Browse files
os-zhuangclaude
andcommitted
ci(spec): public API-surface snapshot gate to catch silent export drift (#2035)
For a metadata-driven platform the spec package IS the third-party API surface. A removed/renamed/kind-changed export silently breaks every consumer pinned to a published release the moment they upgrade (the #2023 class) — and no in-repo consumer catches it, because they all co-evolve with the spec in the same commit. `scripts/build-api-surface.ts` enumerates every exported `name (kind)` from the built `.d.ts` of each public entry point (`.`, `./ui`, `./data`, … 16 entries, 4251 exports), resolving re-export aliases to their real kind. The result is committed at `packages/spec/api-surface.json`. pnpm --filter @objectstack/spec gen:api-surface # regenerate + write pnpm --filter @objectstack/spec check:api-surface # CI: fail on any drift Wired into lint.yml's TypeScript Type Check job (after the build step). A REMOVED export fails as breaking (bump major); an ADDED export still requires regenerating the snapshot, so every change to the public surface is deliberate, never silent. Complements the downstream-contract gate: that proves exercised exports still ACCEPT real third-party metadata (depth); this proves the whole export set still EXISTS (breadth). Dev tooling only — the script and snapshot are not in the package `files`, so nothing ships to consumers. Sort is code-unit (not locale) for cross-platform determinism; verified the check passes clean and rejects a simulated removal. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 92647c1 commit 238e7a6

4 files changed

Lines changed: 4424 additions & 0 deletions

File tree

.github/workflows/lint.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,12 @@ jobs:
107107
# export a published-spec third party already uses. See the package README.
108108
- name: Type check downstream consumer contract
109109
run: pnpm --filter @objectstack/downstream-contract run typecheck
110+
111+
# Public API-surface gate (#2035): the spec package IS the third-party API.
112+
# A removed/renamed export silently breaks every consumer pinned to a
113+
# published release. This diffs the built export surface against the
114+
# committed snapshot; intentional changes regenerate it via
115+
# `pnpm --filter @objectstack/spec gen:api-surface`. Runs after the build
116+
# step above (reads the built dist).
117+
- name: Check @objectstack/spec public API surface
118+
run: pnpm --filter @objectstack/spec run check:api-surface

0 commit comments

Comments
 (0)