# Core contracts and features

Define the behavior, references and composition rules that other parts of a product can share.

Source snapshot: bcc79fcc27c4d801c2119bef81ddcce7b4e86498

## Choose the layer that matches the job

Portable Core owns operation metadata and the existing defineCommand, defineQuery, defineEvent and defineCapability constructors. It also owns feature composition, versioned references and documentation references. Start here to describe a reusable domain boundary. The compatibility package forwards established paths to canonical owners; it remains useful when reading older consumers. A registry, renderer, provider implementation or installed product capability is a separate part of the composition. The current README describes this ownership extraction as staged, so follow the selected release context when deciding what a consumer can adopt.

Source: https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/foundation/contracts-spec/README.md
Source: https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/delivery/contracts-library/src/docs/commands/docsGenerate.command.ts

## Write the contract before the transport

Describe one concrete action or read: its key, version, input, output, error outcomes and declared policy. Identify any emitted event and its relationship to the operation. Put related operations behind a capability, then use a feature to describe the larger composition and its dependencies. Keep documentation close to the definition and reference it explicitly. The source docs.generate operation is a useful complete specimen because its operation, capability requirement and colocated DocBlock can be inspected together.

Source: https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/foundation/contracts-spec/README.md
Source: https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/delivery/contracts-library/src/docs/commands/docsGenerate.command.ts

## Preserve identity while navigating the repository

The same contract may be reachable through a canonical leaf and a historical forwarding path. Compare the selected package export maps before creating a second declaration or duplicating a registry. Treat document revision, operation version and package version as separate identifiers. When a contract changes, inspect its callers, event consumers, presentation bindings and examples. A renamed source folder is an ownership change; it should not silently become a new semantic operation or erase an existing versioned reference.

Source: https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/foundation/contracts-spec/README.md
Source: https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/delivery/contracts-library/src/docs/commands/docsGenerate.command.ts

## Trace one complete operation

Open the definition and record its exact key/version, input and output model, policy and event references. Follow the implementation registration into a runtime package, then the host adapter. This establishes which parts are declarative and which part handles a real request.

Source: https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/foundation/contracts-spec/README.md
Source: https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/delivery/contracts-library/src/docs/commands/docsGenerate.command.ts

## Extend a feature deliberately

List the operation, event, capability and presentation references that the feature actually needs. Reuse their canonical identities and keep optional dependencies visible. Compare a nearby maintained feature rather than guessing a new reference shape.

Source: https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/foundation/contracts-spec/README.md
Source: https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/delivery/contracts-library/src/docs/commands/docsGenerate.command.ts

## Check the consumer boundary

Choose the package and subpath available in the intended release, inspect its forwarding relationship, and run the owning project’s existing validation in that environment. Record the result separately from the fact that a source declaration exists.

Source: https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/foundation/contracts-spec/README.md
Source: https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/delivery/contracts-library/src/docs/commands/docsGenerate.command.ts

## Packages

- [@lssm-tech/lib.contracts-spec-core](https://lssm.co/docs/packages/lib.contracts-spec-core/): Portable ContractSpec feature models, ownership, query, result, approval and reference primitives
- [@lssm-tech/lib.contracts-library](https://lssm.co/docs/packages/lib.contracts-library/): Reusable contract library and registry primitives for ContractSpec applications.
- [@lssm-tech/lib.contracts-spec](https://lssm.co/docs/packages/lib.contracts-spec/): Spec definitions and registries for ContractSpec
- [@lssm-tech/lib.contracts-transformers](https://lssm.co/docs/packages/lib.contracts-transformers/): Contract format transformations: import/export between ContractSpec and external formats (OpenAPI, AsyncAPI, etc.)
- [@lssm-tech/lib.contracts](https://lssm.co/docs/packages/lib.contracts/): Deprecated monolith package split into contracts-spec, contracts-integrations, and contracts-runtime-* packages
- [@lssm-tech/lib.contractspec-catalog](https://lssm.co/docs/packages/lib.contractspec-catalog/): Versioned, machine-readable ContractSpec package and capability catalog.
