Skip to content
ContractSpec
Start here

Package manual · platform

·Core contracts and features

lib.contracts-library

Reusable contract library and registry primitives for ContractSpec applications.

platformlibraryv5.0.4stableservernode
@lssm-tech/lib.contracts-library
bun add @lssm-tech/lib.contracts-library
Package source ↗Manifest ↗

Manifest declarations describe the current workspace; they do not verify registry publication or runtime execution.

Package guide

Contract definitions for library templates and local runtime.

The app-config entries own tenant app blueprint composition, validation, branding and lifecycle contracts. experiments/spec owns their experiment specification and registry prerequisite. These generic application-template surfaces preserve the original nominal registry types and contain no concrete provider binding. Supported contracts-spec/app-config and contracts-spec/experiments/spec imports forward to the same objects.

What It Provides

  • Layer: lib.
  • Consumers: bundle.library.
  • Related ContractSpec packages include @lssm-tech/lib.contracts-spec, @lssm-tech/lib.schema, @lssm-tech/tool.bun, @lssm-tech/tool.typescript.
  • Related ContractSpec packages include @lssm-tech/lib.contracts-spec, @lssm-tech/lib.schema, @lssm-tech/tool.bun, @lssm-tech/tool.typescript.

Installation

npm install @lssm-tech/lib.contracts-library

or

bun add @lssm-tech/lib.contracts-library

Usage

Import the root entrypoint from @lssm-tech/lib.contracts-library, or choose a documented subpath when you only need one part of the package surface.

Feature references in app composition

composeAppConfig from ./app-config/runtime resolves feature references by key. If the composed input carries an explicit version, the registered feature must match it exactly. Strict composition throws the existing missing-reference error on a mismatch. Permissive composition omits the feature and records the requested <key>.v<version> in missing. Key-only references resolve to the feature registered for that key.

checkBrandComposition from ./app-config/brand-composition validates explicit feature versions against the registry and surface versions against the admitted blueprint feature. A refused blueprint key supplies neither capabilities nor operations. The checker uses the same admitted feature for surface validation and operation classification.

Architecture

  • src/index.ts is the root public barrel and package entrypoint.
  • src/templates is part of the package's public or composition surface.

Public Entry Points

  • Export . resolves through ./src/index.ts.
  • Export ./templates resolves through ./src/templates/index.ts.
  • Export ./templates/messaging resolves through ./src/templates/messaging.ts.
  • Export ./templates/recipes resolves through ./src/templates/recipes.ts.
  • Export ./templates/todos resolves through ./src/templates/todos.ts.
  • Export ./app-config/brand-composition resolves through ./src/app-config/brand-composition.ts (defineBrandComposition, checkBrandComposition, indexBrandHosts/resolveBrandHost, selectBrandExperience, resolveBrandAppConfig: composition-only brand specs; every result carries authority: 'composition-only' and grants no authority; not forwarded by contracts-spec or the ./app-config barrel).
  • Export ./examples/maturity resolves through ./src/examples/maturity.ts (evaluateExampleMaturity: the beta/stable/experimental stability gate for example packages; hosts collect files, README and scripts).

Local Commands

  • bun run dev — contractspec-bun-build dev
  • bun run build — contractspec-bun-build build
  • bun run lint — bun run lint:fix
  • bun run lint:check — biome check .
  • bun run lint:fix — biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .
  • bun run typecheck — tsgo --noEmit
  • bun run publish:pkg — bun publish --tolerate-republish --ignore-scripts --verbose
  • bun run publish:pkg:canary — bun publish:pkg --tag canary
  • bun run clean — rm -rf dist
  • bun run build:bundle — contractspec-bun-build transpile
  • bun run build:types — contractspec-bun-build types
  • bun run prebuild — contractspec-bun-build prebuild

Recent Updates

  • Replace eslint+prettier by biomejs to optimize speed.

Notes

  • Template contracts define the shape consumed by bundle.library — breaking changes cascade to all template renderers.
  • Keep contract schemas additive; avoid removing or renaming fields without a migration path.

The explicit editions family owns existing edition composition, storage and evidence helpers. Coach operation declarations and registrars preserve their original schemas and authority requirements. Contract registry, report, installation and CLI declaration leaves retain their existing nominal signatures. The experiments/evaluator leaf owns the original ExperimentEvaluator: random, sticky and targeted allocation, policy and expression callbacks retain their behavior. Built-in targeting-rule expressions use the kernel policy condition grammar with context as the only root and are never run as JavaScript; a rule whose expression fails to parse or evaluate is skipped and reported in targetingErrors and through onTargetingError.

Relationships

THIS PACKAGElib.contracts-library105 import paths

Arrows point from a package to its direct dependency. Counts are derived from captured workspace manifests.

18 declarations

Declared capabilities

Lib Contracts Library

Reusable contract library and registry primitives for ContractSpec applications.

Scripts

  • publish:pkgbun publish --tolerate-republish --ignore-scripts --verbose
  • publish:pkg:canarybun publish:pkg --tag canary
  • cleanrm -rf dist
  • lintbun run lint:fix
  • lint:fixnode ../../../../scripts/biome.cjs check --write --unsafe --only=nursery/useSortedClasses . && node ../../../../scripts/biome.cjs check --write .
  • lint:checknode ../../../../scripts/biome.cjs check .
  • buildcontractspec-bun-build build
  • build:bundlecontractspec-bun-build transpile
  • build:typescontractspec-bun-build types
  • testbun test
  • prebuildcontractspec-bun-build prebuild
  • typechecktsgo --noEmit
  • devcontractspec-bun-build dev