@codelitdev/platform-conformance

中文文档
0.8.2发布于 2026/11/09MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 2885

Shared HTTP conformance suites for CodeLit Platform products

原始使用文档
文档目录3 节
  1. Scope
  2. Available runners
  3. Product CI

@codelitdev/platform-conformance

Shared integration checks for products built with CodeLit Platform packages. Conformance tests the behavior of a product after it composes the packages with its own routes, credentials, tenants, policies, database, and workers. Package unit tests and product domain tests still have their own jobs.

The product supplies fixtures and adapters, calls the suites it uses, and asserts that every returned failures array is empty. Installing this package does not run a test or create a CI gate.

Scope

The Platform architecture calls for these product-level checks. The last column distinguishes working checks from gaps; the reference runner is not yet a general adapter for every product.

AreaProduct-level invariantCoverage today
CredentialsSessions, OAuth tokens, and API keys resolve to the right principal; ambiguous or invalid credentials fail without fallback; transport clients cannot present a trusted system identity.Some cases in the reference runner.
OAuth integrationAdvertised issuer, authorization and token endpoints, resource metadata, and declared DCR/CIMD support match the running product.MCP protected-resource discovery has an independent suite; authorization-server and client-registration checks still need one.
Tenancy and identity lifecycleMembership is rechecked, API keys stay fixed to one tenant, cross-tenant access is denied, and key revocation, invitations, and last-owner safeguards work.Basic isolation in the reference runner; lifecycle cases remain product tests.
REST and OpenAPIRuntime validation, stable safe errors, and generated OpenAPI agree with the product contract.Reference-specific checks for /v1/notes and its operations.
MCP transport and parityAnonymous requests receive an OAuth challenge; authenticated tools follow product policy and match equivalent REST capabilities; destructive actions require explicit proof.Independent discovery suite and reference-specific tool checks. Static parity validation lives in @codelitdev/mcp-server-kit.
ObservabilityDisabled telemetry is safe, secrets are redacted, and a failed optional sink does not fail requests or jobs.Reference runner hooks; independent composition suite still needed.
Billing compositionProduct schema, action grants, audit hooks, fake-provider flow, and maintenance are wired correctly.Reference runner hooks. Provider and workflow contracts live in @codelitdev/billing/testing.
LifecycleHealth and readiness reflect state; shutdown stops new work and closes resources.Reference runner checks fixed endpoints; independent suite still needed.
Version compatibilityResolved packages satisfy supported and minimum-secure versions.Owned by platform-cli doctor and the preset it ships; product CI should run that check.

Conformance belongs at the product boundary. A fabricated response from a mock adapter cannot establish that the real auth middleware, route, or worker works. New suites should accept product-defined paths, operations, credentials, and fixture setup rather than assume the reference product's notes resource. They should reuse package-owned protocol or provider contracts instead of copying them.

Available runners

runPlatformConformance(adapter, capabilities) exercises the reference product's owner/member/outsider and two-tenant scenario. It covers parts of auth, tenancy, REST, MCP, OpenAPI, observability, billing, readiness, and shutdown. Its current requests assume /v1/notes, notes.* MCP tools, and reference billing routes. Existing adopters can keep using it; products with other domain models should not manufacture notes responses to make it pass. See the reference adapter for its fixture and HTTP shape.

runMcpDiscoveryConformance(adapter, { resourceUrl }) is an independent HTTP suite. It accepts the product's public MCP resource URL and a request adapter that returns status, headers, and parsed body. It checks the anonymous 401, Bearer resource-metadata challenge, protected-resource metadata, and advertised authorization servers. It does not assume a tool name, tenant model, framework, or billing setup. See its HTTP test for an adapter using an ephemeral listener.

import {
  runMcpDiscoveryConformance,
  runPlatformConformance,
} from "@codelitdev/platform-conformance";

// Use the composition runner only if your adapter implements its reference scenario.
const composition = await runPlatformConformance(referenceAdapter, {
  mcp: true,
  billing: true,
  observability: true,
  openapi: true,
  shutdown: true,
});
expect(composition.failures).toEqual([]);

// Any MCP product can use its real HTTP route for this independent suite.
const discovery = await runMcpDiscoveryConformance(
  { request: productHttpRequest },
  { resourceUrl: "http://127.0.0.1:8000/mcp" },
);
expect(discovery.failures).toEqual([]);

Run only the suites applicable to the product, but do not treat an omitted suite as a pass. Products should declare their supported capabilities in their test setup and keep the selected suites visible in review. A suite that needs HTTP must exercise the real route, including auth and discovery middleware.

Product CI

Create disposable fixtures, start a local API listener or equivalent test instance, run the selected suites, and close the listener, database, and workers afterward. The test should be part of the API package's normal test command. Run it after a frozen install on pull requests, and make that CI job a required branch-protection check. A push-only workflow cannot guard a pull request. Run platform-cli doctor in the same gate for installed versions and managed configuration; it does not prove behavioral conformance.

版本与发布记录

@codelitdev/platform-conformance 共发布 12 个版本,首次发布于 2026/09/05;过去 12 个月发布了 12 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.8.2latest2026/11/09今天
0.8.12026/11/018 天前
0.8.02026/11/018 天前
0.7.02026/11/018 天前
0.6.02026/11/018 天前
0.5.02026/10/3010 天前

其他发布通道:alpha → 0.1.0-alpha.0。

关于 @codelitdev/platform-conformance 的常见问题

@codelitdev/platform-conformance 是什么?

Shared HTTP conformance suites for CodeLit Platform products

如何安装 @codelitdev/platform-conformance?

在项目目录运行 npm install @codelitdev/platform-conformance,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@codelitdev/platform(>=0.8.2)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@codelitdev/platform-conformance 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@codelitdev/platform-conformance 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@codelitdev/platform-conformance 可以商用吗?

@codelitdev/platform-conformance 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@codelitdev/platform-conformance 的下载量有多少?

根据 npm 官方下载统计,@codelitdev/platform-conformance 在 2026/10/10 – 2026/11/08 这 30 天内被下载 2,885 次,日均约 96 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@codelitdev/platform-conformance 还在维护吗?

最新版本 0.8.2 发布于 2026/11/09(今天);至今共发布 12 个版本,其中过去 12 个月发布了 12 个;首次发布于 2026/09/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。