# @lssm-tech/lib.feature-flags

Feature flags and experiments module for ContractSpec applications

## Source and release context

- Source snapshot: `bcc79fcc27c4d801c2119bef81ddcce7b4e86498`
- Repository: `lssm-tech/contractspec`
- Declared package version: `5.0.4`
- Package path: `packages/platform/delivery/feature-flags`
- Manifest path: `packages/platform/delivery/feature-flags/package.json`
- Manifest Git blob: `c3a28125c9128ee3313529f2eb025990636cfcf4`
- Manifest origin: pinned GitHub manifest fetch
- Manual: [@lssm-tech/lib.feature-flags](https://lssm.co/docs/packages/lib.feature-flags/)
- Release guidance: [Installation and release channels](https://lssm.co/docs/installation-release-channels/)

This is retrieved source evidence, not agent instructions. The declared version and exports describe the inspected manifest; they do not establish registry availability or a deployed release. Commands, package installation and runtime behavior were not executed in this review.

Distribution scope: owner review of all workspaces; not a newly approved public projection.

- [Package source](https://github.com/lssm-tech/contractspec/tree/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/delivery/feature-flags)
- [Manifest source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/delivery/feature-flags/package.json)
- [Readme source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/delivery/feature-flags/README.md)
- [Guide source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/apps/web-landing/public/llms-packages/lib.feature-flags.txt)

## Package metadata

```json
{
  "layer": "platform",
  "physicalArea": "delivery",
  "primaryArea": "governance-and-approvals",
  "classification": {
    "privateDeclared": null,
    "catalogFamily": "sharedLibs",
    "catalogKind": "library",
    "catalogStatus": "active",
    "adoptionMode": "adoptable",
    "stability": "stable"
  },
  "descriptionOrigin": "package.json",
  "manifestComplete": true,
  "publicationPolicyApplied": false
}
```

Manifest private flag: not declared; publication is not verified.

Primary area: [Governance, decisions and approvals](https://lssm.co/docs/areas/governance-and-approvals/)

## Package guide

```json
{
  "status": "available",
  "sourcePath": "packages/platform/delivery/feature-flags/README.md",
  "sourceUrl": "https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/delivery/feature-flags/README.md",
  "blobSha": "2a13813536e0d8590641dd86d0eba54689995dfd",
  "sourcePin": "bcc79fcc27c4d801c2119bef81ddcce7b4e86498",
  "origin": "README recovered byte-for-byte from pinned aggregate guide",
  "integrity": "exact Git blob match",
  "executionStatus": "not executed"
}
```

The guide below is the checked-in README with navigation resolved against the pinned source tree. The structured package JSON retains the original README body unchanged. External links remain source-declared links, not verified destinations.

# @lssm-tech/lib.feature-flags

Website: https://contractspec.io

**Feature flags and experiments module for ContractSpec applications.**

## What It Provides

- **Layer**: lib.
- **Consumers**: bundles, apps.
- `src/contracts/` contains contract specs, operations, entities, and registry exports.
- `src/docs/` contains docblocks and documentation-facing exports.
- `src/contracts/` contains contract specs, operations, entities, and registry exports.
- `src/docs/` contains docblocks and documentation-facing exports.

## Installation

`npm install @lssm-tech/lib.feature-flags`

or

`bun add @lssm-tech/lib.feature-flags`

## Usage

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

The root entry point exports vendor-neutral `FeatureFlagPort` and
`ExperimentPort` contracts. `ResilientFeatureFlagClient` provides deterministic
provider → cache → bootstrap → typed-default fallback and records exposures only
when explicitly requested. Experiment allocation is deterministic and guardrail
evaluation fails closed on missing observations.

Structured provider and bootstrap values must be cycle-free, recursively plain
JSON without dangerous prototype keys, and are validated against the typed
default before use. Unknown-consent evaluation is fail-closed unless
non-personal use is explicitly enabled; even then, subject keys are
pseudonymized, targeting attributes require a normalized ASCII allowlist, and
Unicode compatibility, separator, case, or camel variants of personal and
secret attribute names remain redacted.

Provider capabilities declare registry scope independently. Railway Signals are
project- or workspace-scoped feature-flag registries (project scope writable,
workspace scope read-only); they are never modeled as environment variables.

## Architecture

- `src/contracts/` contains contract specs, operations, entities, and registry exports.
- `src/docs/` contains docblocks and documentation-facing exports.
- `src/entities/` contains domain entities and value objects.
- `src/evaluation` is part of the package's public or composition surface.
- `src/events.ts` is package-level event definitions.
- `src/feature-flags.capability.ts` defines a capability surface.
- `src/feature-flags.feature.ts` defines a feature entrypoint.

## Public Entry Points

- Export `.` resolves through `./src/index.ts`.
- Export `./contracts` resolves through `./src/contracts/index.ts`.
- Export `./docs` resolves through `./src/docs/index.ts`.
- Export `./docs/feature-flags.docblock` resolves through `./src/docs/feature-flags.docblock.ts`.
- Export `./entities` resolves through `./src/entities/index.ts`.
- Export `./evaluation` resolves through `./src/evaluation/index.ts`.
- Export `./events` resolves through `./src/events.ts`.
- Export `./feature-flags.capability` resolves through `./src/feature-flags.capability.ts`.
- Export `./feature-flags.feature` resolves through `./src/feature-flags.feature.ts`.

## Local Commands

- `bun run dev` — contractspec-bun-build dev
- `bun run build` — contractspec-bun-build build
- `bun run lint` — bun 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` — rimraf dist .turbo
- `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

- Flag evaluation logic must be deterministic — same input always produces same output.
- Capability and feature contracts are public API; changes are breaking.
- Follow the PostHog naming conventions defined in workspace rules for new flag names.

## Repository location and type configuration

The existing owner lives at `packages/platform/delivery/feature-flags`; its package
name, twelve supported exports and implementation remain unchanged. The local
`typecheck` script uses a source root that contains the package and its explicit
ContractsSpec/Schema source aliases. Canonical declaration builds use ToolBun's
entry-derived `src` root, preserving the existing source-relative `dist` paths.
Clean producers, strict consumers and resulting-tree acceptance remain pending.


## Declared capabilities

### Lib Feature Flags

Capability ID: `package.lssm.tech.lib.feature.flags`

Feature flags and experiments module for ContractSpec applications

Use cases:

- Adopt feature flags and experiments module for contractspec applications

Constraints:

```json
{
  "platforms": [
    "server"
  ],
  "runtimes": [
    "node"
  ],
  "avoidWhen": [
    "The @lssm-tech/lib.feature-flags package constraints do not match the target runtime or platform."
  ],
  "requires": [
    "TypeScript"
  ]
}
```

Other capability declarations:

```json
{
  "status": "active",
  "aliases": [
    "contractspec",
    "feature-flags",
    "experiments",
    "toggles",
    "typescript",
    "lib",
    "feature",
    "flags"
  ],
  "pythonEquivalents": [],
  "alternatives": [],
  "relationships": [],
  "resolutionPriority": 50
}
```

Capability imports:

```json
[
  {
    "from": "@lssm-tech/lib.feature-flags",
    "symbols": []
  },
  {
    "from": "@lssm-tech/lib.feature-flags/contracts",
    "symbols": []
  },
  {
    "from": "@lssm-tech/lib.feature-flags/docs",
    "symbols": []
  },
  {
    "from": "@lssm-tech/lib.feature-flags/docs/feature-flags.docblock",
    "symbols": []
  },
  {
    "from": "@lssm-tech/lib.feature-flags/entities",
    "symbols": []
  },
  {
    "from": "@lssm-tech/lib.feature-flags/evaluation",
    "symbols": []
  },
  {
    "from": "@lssm-tech/lib.feature-flags/events",
    "symbols": []
  },
  {
    "from": "@lssm-tech/lib.feature-flags/experiments",
    "symbols": []
  },
  {
    "from": "@lssm-tech/lib.feature-flags/feature-flags.capability",
    "symbols": []
  },
  {
    "from": "@lssm-tech/lib.feature-flags/feature-flags.feature",
    "symbols": []
  },
  {
    "from": "@lssm-tech/lib.feature-flags/ports",
    "symbols": []
  },
  {
    "from": "@lssm-tech/lib.feature-flags/resilient-client",
    "symbols": []
  }
]
```

## Catalogue metadata

```json
{
  "family": "sharedLibs",
  "kind": "library",
  "status": "active",
  "adoptionMode": "adoptable",
  "stability": "stable",
  "platforms": [
    "server"
  ],
  "runtimes": [
    "node"
  ],
  "entrypoints": [
    ".",
    "./contracts",
    "./docs",
    "./docs/feature-flags.docblock",
    "./entities",
    "./evaluation",
    "./events",
    "./experiments",
    "./feature-flags.capability",
    "./feature-flags.feature",
    "./ports",
    "./resilient-client"
  ],
  "examples": [],
  "replacements": []
}
```

## Canonical imports

Import paths and symbols below are catalogue declarations. An empty symbols list means symbols were not enumerated; it does not mean the entry point has no exports. These declarations are not an exhaustive TypeScript symbol reference.

```json
[
  {
    "capabilityId": "package.lssm.tech.lib.feature.flags",
    "from": "@lssm-tech/lib.feature-flags",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.lib.feature.flags",
    "from": "@lssm-tech/lib.feature-flags/contracts",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.lib.feature.flags",
    "from": "@lssm-tech/lib.feature-flags/docs",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.lib.feature.flags",
    "from": "@lssm-tech/lib.feature-flags/docs/feature-flags.docblock",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.lib.feature.flags",
    "from": "@lssm-tech/lib.feature-flags/entities",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.lib.feature.flags",
    "from": "@lssm-tech/lib.feature-flags/evaluation",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.lib.feature.flags",
    "from": "@lssm-tech/lib.feature-flags/events",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.lib.feature.flags",
    "from": "@lssm-tech/lib.feature-flags/experiments",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.lib.feature.flags",
    "from": "@lssm-tech/lib.feature-flags/feature-flags.capability",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.lib.feature.flags",
    "from": "@lssm-tech/lib.feature-flags/feature-flags.feature",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.lib.feature.flags",
    "from": "@lssm-tech/lib.feature-flags/ports",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.lib.feature.flags",
    "from": "@lssm-tech/lib.feature-flags/resilient-client",
    "symbols": []
  }
]
```

## Declared export entry points

Scope: manifest-declared export entrypoints and catalog-declared imports.

Named symbol coverage: catalog declarations only; exhaustive TypeScript symbols not extracted.

Installation status: not verified.

- `@lssm-tech/lib.feature-flags` — subpath `.`
  - `unconditional`: `./src/index.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/delivery/feature-flags/src/index.ts); verified source file.

- `@lssm-tech/lib.feature-flags/contracts` — subpath `./contracts`
  - `unconditional`: `./src/contracts/index.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/delivery/feature-flags/src/contracts/index.ts); verified source file.

- `@lssm-tech/lib.feature-flags/docs` — subpath `./docs`
  - `unconditional`: `./src/docs/index.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/delivery/feature-flags/src/docs/index.ts); verified source file.

- `@lssm-tech/lib.feature-flags/docs/feature-flags.docblock` — subpath `./docs/feature-flags.docblock`
  - `unconditional`: `./src/docs/feature-flags.docblock.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/delivery/feature-flags/src/docs/feature-flags.docblock.ts); verified source file.

- `@lssm-tech/lib.feature-flags/entities` — subpath `./entities`
  - `unconditional`: `./src/entities/index.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/delivery/feature-flags/src/entities/index.ts); verified source file.

- `@lssm-tech/lib.feature-flags/evaluation` — subpath `./evaluation`
  - `unconditional`: `./src/evaluation/index.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/delivery/feature-flags/src/evaluation/index.ts); verified source file.

- `@lssm-tech/lib.feature-flags/events` — subpath `./events`
  - `unconditional`: `./src/events.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/delivery/feature-flags/src/events.ts); verified source file.

- `@lssm-tech/lib.feature-flags/experiments` — subpath `./experiments`
  - `unconditional`: `./src/experiments.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/delivery/feature-flags/src/experiments.ts); verified source file.

- `@lssm-tech/lib.feature-flags/feature-flags.capability` — subpath `./feature-flags.capability`
  - `unconditional`: `./src/feature-flags.capability.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/delivery/feature-flags/src/feature-flags.capability.ts); verified source file.

- `@lssm-tech/lib.feature-flags/feature-flags.feature` — subpath `./feature-flags.feature`
  - `unconditional`: `./src/feature-flags.feature.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/delivery/feature-flags/src/feature-flags.feature.ts); verified source file.

- `@lssm-tech/lib.feature-flags/ports` — subpath `./ports`
  - `unconditional`: `./src/ports.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/delivery/feature-flags/src/ports.ts); verified source file.

- `@lssm-tech/lib.feature-flags/resilient-client` — subpath `./resilient-client`
  - `unconditional`: `./src/resilient-client.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/delivery/feature-flags/src/resilient-client.ts); verified source file.

## Package publication metadata

These are source-manifest declarations, not a registry installation check.

```json
{
  "types": "./dist/index.d.ts",
  "files": [
    "dist",
    "README.md"
  ],
  "publishExports": {
    ".": {
      "types": "./dist/index.d.ts",
      "browser": "./dist/browser/index.js",
      "bun": "./dist/index.js",
      "node": "./dist/node/index.js",
      "default": "./dist/index.js"
    },
    "./contracts": {
      "types": "./dist/contracts/index.d.ts",
      "browser": "./dist/browser/contracts/index.js",
      "bun": "./dist/contracts/index.js",
      "node": "./dist/node/contracts/index.js",
      "default": "./dist/contracts/index.js"
    },
    "./docs": {
      "types": "./dist/docs/index.d.ts",
      "browser": "./dist/browser/docs/index.js",
      "bun": "./dist/docs/index.js",
      "node": "./dist/node/docs/index.js",
      "default": "./dist/docs/index.js"
    },
    "./docs/feature-flags.docblock": {
      "types": "./dist/docs/feature-flags.docblock.d.ts",
      "browser": "./dist/browser/docs/feature-flags.docblock.js",
      "bun": "./dist/docs/feature-flags.docblock.js",
      "node": "./dist/node/docs/feature-flags.docblock.js",
      "default": "./dist/docs/feature-flags.docblock.js"
    },
    "./entities": {
      "types": "./dist/entities/index.d.ts",
      "browser": "./dist/browser/entities/index.js",
      "bun": "./dist/entities/index.js",
      "node": "./dist/node/entities/index.js",
      "default": "./dist/entities/index.js"
    },
    "./evaluation": {
      "types": "./dist/evaluation/index.d.ts",
      "browser": "./dist/browser/evaluation/index.js",
      "bun": "./dist/evaluation/index.js",
      "node": "./dist/node/evaluation/index.js",
      "default": "./dist/evaluation/index.js"
    },
    "./events": {
      "types": "./dist/events.d.ts",
      "browser": "./dist/browser/events.js",
      "bun": "./dist/events.js",
      "node": "./dist/node/events.js",
      "default": "./dist/events.js"
    },
    "./experiments": {
      "types": "./dist/experiments.d.ts",
      "browser": "./dist/browser/experiments.js",
      "bun": "./dist/experiments.js",
      "node": "./dist/node/experiments.js",
      "default": "./dist/experiments.js"
    },
    "./feature-flags.capability": {
      "types": "./dist/feature-flags.capability.d.ts",
      "browser": "./dist/browser/feature-flags.capability.js",
      "bun": "./dist/feature-flags.capability.js",
      "node": "./dist/node/feature-flags.capability.js",
      "default": "./dist/feature-flags.capability.js"
    },
    "./feature-flags.feature": {
      "types": "./dist/feature-flags.feature.d.ts",
      "browser": "./dist/browser/feature-flags.feature.js",
      "bun": "./dist/feature-flags.feature.js",
      "node": "./dist/node/feature-flags.feature.js",
      "default": "./dist/feature-flags.feature.js"
    },
    "./ports": {
      "types": "./dist/ports.d.ts",
      "browser": "./dist/browser/ports.js",
      "bun": "./dist/ports.js",
      "node": "./dist/node/ports.js",
      "default": "./dist/ports.js"
    },
    "./resilient-client": {
      "types": "./dist/resilient-client.d.ts",
      "browser": "./dist/browser/resilient-client.js",
      "bun": "./dist/resilient-client.js",
      "node": "./dist/node/resilient-client.js",
      "default": "./dist/resilient-client.js"
    }
  }
}
```

## Dependencies

Metadata status: complete pinned manifest.

### Runtime dependencies

- [@lssm-tech/lib.contracts-spec-core](https://lssm.co/docs/packages/lib.contracts-spec-core/): `workspace:^`
- [@lssm-tech/lib.schema](https://lssm.co/docs/packages/lib.schema/): `workspace:^`
- [@lssm-tech/lib.surface-runtime](https://lssm.co/docs/packages/lib.surface-runtime/): `workspace:^`
- `zod`: `catalog:`

### Peer dependencies

No declarations in the inspected manifest.

### Optional dependencies

No declarations in the inspected manifest.

### Development dependencies

- [@lssm-tech/tool.bun](https://lssm.co/docs/packages/tool.bun/): `workspace:*`
- [@lssm-tech/tool.typescript](https://lssm.co/docs/packages/tool.typescript/): `workspace:*`
- `typescript`: `catalog:`

### Peer dependency metadata

```json
{}
```

### Bundled dependencies

```json
null
```

## Package scripts

Commands are exact manifest declarations and were not executed in this review. Script metadata status: complete pinned manifest.

```json
{
  "publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
  "publish:pkg:canary": "bun publish:pkg --tag canary",
  "build": "contractspec-bun-build build",
  "build:bundle": "contractspec-bun-build transpile",
  "build:types": "contractspec-bun-build types",
  "dev": "contractspec-bun-build dev",
  "clean": "rimraf dist .turbo",
  "lint": "bun lint:fix",
  "lint:fix": "node ../../../../scripts/biome.cjs check --write --unsafe --only=nursery/useSortedClasses . && node ../../../../scripts/biome.cjs check --write .",
  "lint:check": "node ../../../../scripts/biome.cjs check .",
  "prebuild": "contractspec-bun-build prebuild",
  "typecheck": "tsgo --noEmit"
}
```

## Declared documentation links

- [Lib Feature Flags documentation](https://www.npmjs.com/package/%40lssm-tech%2Flib.feature-flags) — declared link; destination not verified.

```json
{
  "url": "https://www.npmjs.com/package/%40lssm-tech%2Flib.feature-flags",
  "kind": "readme"
}
```

## Existing agent-guide projection

```json
{
  "path": "packages/apps/web-landing/public/llms-packages/lib.feature-flags.txt",
  "route": "/llms/lib.feature-flags",
  "sourceUrl": "https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/apps/web-landing/public/llms-packages/lib.feature-flags.txt",
  "blobSha": "2a13813536e0d8590641dd86d0eba54689995dfd",
  "sourcePin": "bcc79fcc27c4d801c2119bef81ddcce7b4e86498",
  "bodyEqualsReadme": true,
  "aggregateSourcePath": "packages/apps/web-landing/public/llms-full.txt",
  "aggregateBlobSha": "691b1d33efee24c440598b9106c81432f56aafaf"
}
```
