# @lssm-tech/lib.work-runtime

Pure Work Graph reducers, event processing, recurrence, idempotency, and sync conflict decisions.

## Source and release context

- Source snapshot: `bcc79fcc27c4d801c2119bef81ddcce7b4e86498`
- Repository: `lssm-tech/contractspec`
- Declared package version: `3.0.4`
- Package path: `packages/domains/work/runtime`
- Manifest path: `packages/domains/work/runtime/package.json`
- Manifest Git blob: `90f692bf4325854e5e897c38154b5c067cdd1010`
- Manifest origin: pinned GitHub manifest fetch
- Manual: [@lssm-tech/lib.work-runtime](https://lssm.co/docs/packages/lib.work-runtime/)
- 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/domains/work/runtime)
- [Manifest source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/domains/work/runtime/package.json)
- [Readme source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/domains/work/runtime/README.md)
- [Guide source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/apps/web-landing/public/llms-packages/lib.work-runtime.txt)

## Package metadata

```json
{
  "layer": "domains",
  "physicalArea": "work",
  "primaryArea": "company-and-work",
  "classification": {
    "privateDeclared": null,
    "catalogFamily": "runtime",
    "catalogKind": "library",
    "catalogStatus": "active",
    "adoptionMode": "adoptable",
    "stability": "experimental"
  },
  "descriptionOrigin": "package.json",
  "manifestComplete": true,
  "publicationPolicyApplied": false
}
```

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

Primary area: [Company, work and service operations](https://lssm.co/docs/areas/company-and-work/)

## Package guide

```json
{
  "status": "available",
  "sourcePath": "packages/domains/work/runtime/README.md",
  "sourceUrl": "https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/domains/work/runtime/README.md",
  "blobSha": "d5159bdc4bb83b7fbbb0cec79c4ea82800f372c6",
  "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.work-runtime`

Pure, provider-neutral Work Graph runtime behavior.

It reduces immutable Work events, enforces aggregate revision order, expands
recurrence, applies native/remote/merge field authority, detects three-way
scalar conflicts, and exposes storage/projection ports. Concrete PostgreSQL,
queue, search, realtime, connector, and object-store adapters belong in
integrations. Unknown event types, revision gaps, open merge conflicts, and
aggregate identity or scope drift are rejected fail-closed.

`./outbox-dispatch` supplies the provider-neutral worker boundary for
projection, authorized realtime, and OPA reoptimization delivery. It requires
destination-specific leased records and owner-fenced acknowledgements from the
durable adapter; unknown destinations or missing consumers fail closed.

Durable command ports expose optional `lookupCommitted` so services can resolve an authorized retry before object-existence or revision validation. The PostgreSQL adapter fences the request identity and returns its persisted receipt, or an idempotency conflict for changed input. Managed hosts keep lookup, projection reads and commit in one outer authority transaction, so concurrent identical creates return one committed event. Other adapters must implement this receipt lookup to qualify equivalent retry behavior.

Work outbox lease contract v2 requires `deliveryAttempt` on acknowledge/release, copied from the claimed record's `deliveryAttempts`. The dispatcher supplies it automatically. Matching a worker name and future expiry is insufficient: settlement also checks the exact persisted attempt. Old or missing attempt values fail closed. Update custom callers before upgrading; no database migration or stored-record reset is required.

`./task-status` holds the pure task status transition used by managed hosts:
`planWorkTaskStatusMutation` builds the `work.object.transition@2.0.0`
envelope and request fingerprint from an injected digest, and
`transitionWorkTaskStatus` applies the change to the current task at the
displayed revision (category change clears the custom status id, completion
uses server time and keeps an earlier completion, reopening clears it). Both
fail closed with `WorkTaskStatusConflict`. Hosts keep authority, the store and
the transaction.


## Declared capabilities

### Lib Work Runtime

Capability ID: `package.lssm.tech.lib.work.runtime`

Pure Work Graph reducers, event processing, recurrence, idempotency, and sync conflict decisions.

Use cases:

- Adopt pure work graph reducers, event processing, recurrence, idempotency, and sync conflict decisions

Constraints:

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

Other capability declarations:

```json
{
  "status": "active",
  "aliases": [
    "lib",
    "work",
    "runtime"
  ],
  "pythonEquivalents": [],
  "alternatives": [],
  "relationships": [],
  "resolutionPriority": 50
}
```

Capability imports:

```json
[
  {
    "from": "@lssm-tech/lib.work-runtime",
    "symbols": []
  },
  {
    "from": "@lssm-tech/lib.work-runtime/idempotency",
    "symbols": []
  },
  {
    "from": "@lssm-tech/lib.work-runtime/outbox-dispatch",
    "symbols": []
  },
  {
    "from": "@lssm-tech/lib.work-runtime/ports",
    "symbols": []
  },
  {
    "from": "@lssm-tech/lib.work-runtime/recurrence",
    "symbols": []
  },
  {
    "from": "@lssm-tech/lib.work-runtime/reducer",
    "symbols": []
  },
  {
    "from": "@lssm-tech/lib.work-runtime/sync",
    "symbols": []
  },
  {
    "from": "@lssm-tech/lib.work-runtime/task-status",
    "symbols": []
  }
]
```

## Catalogue metadata

```json
{
  "family": "runtime",
  "kind": "library",
  "status": "active",
  "adoptionMode": "adoptable",
  "stability": "experimental",
  "platforms": [
    "server"
  ],
  "runtimes": [
    "node"
  ],
  "entrypoints": [
    ".",
    "./idempotency",
    "./outbox-dispatch",
    "./ports",
    "./recurrence",
    "./reducer",
    "./sync",
    "./task-status"
  ],
  "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.work.runtime",
    "from": "@lssm-tech/lib.work-runtime",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.lib.work.runtime",
    "from": "@lssm-tech/lib.work-runtime/idempotency",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.lib.work.runtime",
    "from": "@lssm-tech/lib.work-runtime/outbox-dispatch",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.lib.work.runtime",
    "from": "@lssm-tech/lib.work-runtime/ports",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.lib.work.runtime",
    "from": "@lssm-tech/lib.work-runtime/recurrence",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.lib.work.runtime",
    "from": "@lssm-tech/lib.work-runtime/reducer",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.lib.work.runtime",
    "from": "@lssm-tech/lib.work-runtime/sync",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.lib.work.runtime",
    "from": "@lssm-tech/lib.work-runtime/task-status",
    "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.work-runtime` — subpath `.`
  - `unconditional`: `./src/index.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/domains/work/runtime/src/index.ts); verified source file.

- `@lssm-tech/lib.work-runtime/idempotency` — subpath `./idempotency`
  - `unconditional`: `./src/idempotency.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/domains/work/runtime/src/idempotency.ts); verified source file.

- `@lssm-tech/lib.work-runtime/outbox-dispatch` — subpath `./outbox-dispatch`
  - `unconditional`: `./src/outbox-dispatch.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/domains/work/runtime/src/outbox-dispatch.ts); verified source file.

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

- `@lssm-tech/lib.work-runtime/recurrence` — subpath `./recurrence`
  - `unconditional`: `./src/recurrence.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/domains/work/runtime/src/recurrence.ts); verified source file.

- `@lssm-tech/lib.work-runtime/reducer` — subpath `./reducer`
  - `unconditional`: `./src/reducer.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/domains/work/runtime/src/reducer.ts); verified source file.

- `@lssm-tech/lib.work-runtime/sync` — subpath `./sync`
  - `unconditional`: `./src/sync.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/domains/work/runtime/src/sync.ts); verified source file.

- `@lssm-tech/lib.work-runtime/task-status` — subpath `./task-status`
  - `unconditional`: `./src/task-status.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/domains/work/runtime/src/task-status.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"
    },
    "./idempotency": {
      "types": "./dist/idempotency.d.ts",
      "browser": "./dist/browser/idempotency.js",
      "bun": "./dist/idempotency.js",
      "node": "./dist/node/idempotency.js",
      "default": "./dist/idempotency.js"
    },
    "./outbox-dispatch": {
      "types": "./dist/outbox-dispatch.d.ts",
      "browser": "./dist/browser/outbox-dispatch.js",
      "bun": "./dist/outbox-dispatch.js",
      "node": "./dist/node/outbox-dispatch.js",
      "default": "./dist/outbox-dispatch.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"
    },
    "./recurrence": {
      "types": "./dist/recurrence.d.ts",
      "browser": "./dist/browser/recurrence.js",
      "bun": "./dist/recurrence.js",
      "node": "./dist/node/recurrence.js",
      "default": "./dist/recurrence.js"
    },
    "./reducer": {
      "types": "./dist/reducer.d.ts",
      "browser": "./dist/browser/reducer.js",
      "bun": "./dist/reducer.js",
      "node": "./dist/node/reducer.js",
      "default": "./dist/reducer.js"
    },
    "./sync": {
      "types": "./dist/sync.d.ts",
      "browser": "./dist/browser/sync.js",
      "bun": "./dist/sync.js",
      "node": "./dist/node/sync.js",
      "default": "./dist/sync.js"
    },
    "./task-status": {
      "types": "./dist/task-status.d.ts",
      "browser": "./dist/browser/task-status.js",
      "bun": "./dist/task-status.js",
      "node": "./dist/node/task-status.js",
      "default": "./dist/task-status.js"
    }
  }
}
```

## Dependencies

Metadata status: complete pinned manifest.

### Runtime dependencies

- [@lssm-tech/lib.work-spec](https://lssm.co/docs/packages/lib.work-spec/): `workspace:^`

### 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 .",
  "lint:check": "node ../../../../scripts/biome.cjs check .",
  "test": "bun test",
  "prebuild": "contractspec-bun-build prebuild",
  "typecheck": "tsgo --noEmit"
}
```

## Declared documentation links

- [Lib Work Runtime documentation](https://www.npmjs.com/package/%40lssm-tech%2Flib.work-runtime) — declared link; destination not verified.

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

## Existing agent-guide projection

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