# @lssm-tech/lib.work-spec

Canonical provider-neutral Work Graph contracts for CompanyOS and modular Work OS consumers.

## Source and release context

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

## Package metadata

```json
{
  "layer": "domains",
  "physicalArea": "work",
  "primaryArea": "company-and-work",
  "classification": {
    "privateDeclared": null,
    "catalogFamily": "contracts",
    "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/spec/README.md",
  "sourceUrl": "https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/domains/work/spec/README.md",
  "blobSha": "29b80127b17801a1dbfbf6e36432136775bd8a33",
  "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-spec`

Canonical provider-neutral Work Graph contracts for CompanyOS and independent
downstream products.

The package owns opaque UUIDv7 work identity, tenant structure, strategy and
execution objects, organization metadata, collaboration metadata, personal
productivity records, external bindings, sync conflicts, immutable events,
mutation envelopes, and capability manifests.

Custom-field definitions and values are native contracts. A value always
references both its `custom_field_definition` and the Work object it applies to;
provider-specific fields remain external binding payloads rather than becoming
canonical required fields.

`WorkObjectRef.kind` is restricted to the canonical Work taxonomy. Events are
explicit and immutable: object lifecycle, recurrence configuration, time
tracking, relationship, comment-creation, and attachment-link events. Recurrence
rules are attached to recurrence-template aggregates; time entries, comments,
and attachment links are attached to their tracked Work aggregate. Relationship
events are attached to their source aggregate, including blocking dependencies
consumed by OPA planning projections.

It does not schedule work, call providers, persist data, evaluate CompanyOS
authority, or store collaborative document bodies. OPA owns actual placement;
CRDT packages own document and canvas bodies.

```ts
import {
  WorkObjectSchema,
  WorkMutationEnvelopeSchema,
  WorkObjectRefSchema,
} from "@lssm-tech/lib.work-spec";
```


Production integrations must map provider IDs into external bindings and
declare field-group authority. They must never substitute remote identity for a
canonical Work ID.

Managed host implementations must satisfy `WORK_MANAGED_COMMIT_AUTHORITY_CONTRACT`: keep current organization/session/workspace/team authority and canonical Work event/outbox persistence in one transaction. A caller-selected action label never grants mutation authority. Existing operation envelopes and canonical identity bindings remain unchanged.

### Canonical Work hierarchy and legacy parity

Apply additive migration 0081 after 0080 before enabling new Work identity allocation. New operators reuse canonical tenant/organization/workspace IDs for the same verified legacy scope, and a principal retains its canonical ID across workspaces within a tenant. The database enforces this during mixed-version rollout; new allocation is serialized per legacy tenant. Existing bindings are read without taking the allocation lock.

Existing rows and Work events remain intact. A coherent legacy mapping is adopted for new operators; conflicting parent or principal mappings block new allocation with `WORK_IDENTITY_RECONCILIATION_REQUIRED`. Use `inspectWorkIdentityParity` inside an authorized transaction with the physical tenant GUC set to inventory conflicts. It reports scope categories and counts without rewriting data. Do not pick an arbitrary legacy ID or rewrite immutable Work events to clear the error. A reviewed reconciliation and parity/restore proof are required before enabling shared projection for a conflicted tenant.

The preparation function rejects foreign scope or unavailable trigger enforcement. Personal-context provisioning uses distinct physical tenants/workspaces, which remain isolated. This change is locally verified on PostgreSQL 15; production migration and existing-data reconciliation remain separate release gates.


Work scope validation now includes tenant, organization and workspace on object reads, including both materialized projections and replay fallback. Mismatched projection identities fail closed. Mutation services validate the current object's identity/scope and replay receipts against the authorized actor and scope. PostgreSQL commits serialize by aggregate before revision checks and reject changing an existing aggregate's scope; projection upserts cannot replace a newer revision with an older worker result. These changes preserve existing wire contracts and require no schema migration. Tenant-only event/outbox worker ports remain trusted internal surfaces and must not be exposed as workspace-authorized reads.


Work object reads compare materialized projection revision with the committed event head in one SQL snapshot. A lagging or missing projection falls back to scoped event replay, so committed updates, archives and restores are visible without waiting for the outbox worker. Returned metadata carries the current aggregate revision, including lifecycle-only events. Reads do not mutate projections. Long aggregate histories still require performance qualification.


`GET /api/companyos/work/objects/:objectId` reads a canonical UUIDv7 Work object under current server-derived workspace authority. The request accepts no scope parameters. Existing coherent canonical workspace mappings are read without allocation; conflicting mappings fail closed. The API uses the scoped, event-head-aware Work store and reproves read authority before returning. Responses are private/no-store, and absent, foreign or archived objects return not found. Native task-detail presentation is separate qualification work.


POST `/api/companyos/work/objects/:objectId/status` accepts only a canonical object ID, expected revision, status category and idempotency key. Current writable authority and actor/scope are derived server-side inside the transaction. The existing Work service commits status changes and three outbox destinations atomically. Completion uses server time; reopening clears completion time. Identical retries resolve the stored event before current-state validation. Native controls and live end-to-end qualification remain open.

Work outbox lease validity uses the PostgreSQL clock. A caller availability cutoff cannot expire another worker’s active lease, and expired leases cannot acknowledge or release work even before replacement. Settlement checks expiry again in its conditional write. Hosts must still use distinct claim identities and authorize effects independently; this does not activate the OPA consumer.

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.

Workspace revision fencing hashes every canonical Work aggregate head, including unplaced, completed and archived work. Work commits take a shared workspace advisory lock; proposal publication takes its exclusive counterpart and checks the complete digest before persistence. The interactive planner and internal background proposal publisher use this fence. Upgrade all Work writers before qualifying it; older writers that omit the shared lock are not covered. Calendar freshness and policy/approval checks remain independent.


## Declared capabilities

### Lib Work Spec

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

Canonical provider-neutral Work Graph contracts for CompanyOS and modular Work OS consumers.

Use cases:

- Adopt canonical provider-neutral work graph contracts for companyos and modular work os consumers

Constraints:

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

Other capability declarations:

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

Capability imports:

```json
[
  {
    "from": "@lssm-tech/lib.work-spec",
    "symbols": []
  },
  {
    "from": "@lssm-tech/lib.work-spec/capabilities",
    "symbols": []
  },
  {
    "from": "@lssm-tech/lib.work-spec/common",
    "symbols": []
  },
  {
    "from": "@lssm-tech/lib.work-spec/entities",
    "symbols": []
  },
  {
    "from": "@lssm-tech/lib.work-spec/events",
    "symbols": []
  },
  {
    "from": "@lssm-tech/lib.work-spec/models",
    "symbols": []
  },
  {
    "from": "@lssm-tech/lib.work-spec/operations",
    "symbols": []
  },
  {
    "from": "@lssm-tech/lib.work-spec/sync",
    "symbols": []
  },
  {
    "from": "@lssm-tech/lib.work-spec/taxonomy",
    "symbols": []
  },
  {
    "from": "@lssm-tech/lib.work-spec/work-spec.feature",
    "symbols": []
  }
]
```

## Catalogue metadata

```json
{
  "family": "contracts",
  "kind": "library",
  "status": "active",
  "adoptionMode": "adoptable",
  "stability": "experimental",
  "platforms": [
    "server"
  ],
  "runtimes": [
    "node"
  ],
  "entrypoints": [
    ".",
    "./capabilities",
    "./common",
    "./entities",
    "./events",
    "./models",
    "./operations",
    "./sync",
    "./taxonomy",
    "./work-spec.feature"
  ],
  "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.spec",
    "from": "@lssm-tech/lib.work-spec",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.lib.work.spec",
    "from": "@lssm-tech/lib.work-spec/capabilities",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.lib.work.spec",
    "from": "@lssm-tech/lib.work-spec/common",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.lib.work.spec",
    "from": "@lssm-tech/lib.work-spec/entities",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.lib.work.spec",
    "from": "@lssm-tech/lib.work-spec/events",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.lib.work.spec",
    "from": "@lssm-tech/lib.work-spec/models",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.lib.work.spec",
    "from": "@lssm-tech/lib.work-spec/operations",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.lib.work.spec",
    "from": "@lssm-tech/lib.work-spec/sync",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.lib.work.spec",
    "from": "@lssm-tech/lib.work-spec/taxonomy",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.lib.work.spec",
    "from": "@lssm-tech/lib.work-spec/work-spec.feature",
    "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-spec` — subpath `.`
  - `unconditional`: `./src/index.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/domains/work/spec/src/index.ts); verified source file.

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

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

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

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

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

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

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

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

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

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

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

- `@lssm-tech/lib.work-spec/workspace-revision` — subpath `./workspace-revision`
  - `unconditional`: `./src/workspace-revision.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/domains/work/spec/src/workspace-revision.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"
    },
    "./capabilities": {
      "types": "./dist/capabilities.d.ts",
      "browser": "./dist/browser/capabilities.js",
      "bun": "./dist/capabilities.js",
      "node": "./dist/node/capabilities.js",
      "default": "./dist/capabilities.js"
    },
    "./common": {
      "types": "./dist/common.d.ts",
      "browser": "./dist/browser/common.js",
      "bun": "./dist/common.js",
      "node": "./dist/node/common.js",
      "default": "./dist/common.js"
    },
    "./entities": {
      "types": "./dist/entities.d.ts",
      "browser": "./dist/browser/entities.js",
      "bun": "./dist/entities.js",
      "node": "./dist/node/entities.js",
      "default": "./dist/entities.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"
    },
    "./models": {
      "types": "./dist/models.d.ts",
      "browser": "./dist/browser/models.js",
      "bun": "./dist/models.js",
      "node": "./dist/node/models.js",
      "default": "./dist/models.js"
    },
    "./object-read": {
      "types": "./dist/object-read.d.ts",
      "browser": "./dist/browser/object-read.js",
      "bun": "./dist/object-read.js",
      "node": "./dist/node/object-read.js",
      "default": "./dist/object-read.js"
    },
    "./operations": {
      "types": "./dist/operations.d.ts",
      "browser": "./dist/browser/operations.js",
      "bun": "./dist/operations.js",
      "node": "./dist/node/operations.js",
      "default": "./dist/operations.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"
    },
    "./taxonomy": {
      "types": "./dist/taxonomy.d.ts",
      "browser": "./dist/browser/taxonomy.js",
      "bun": "./dist/taxonomy.js",
      "node": "./dist/node/taxonomy.js",
      "default": "./dist/taxonomy.js"
    },
    "./work-spec.feature": {
      "types": "./dist/work-spec.feature.d.ts",
      "browser": "./dist/browser/work-spec.feature.js",
      "bun": "./dist/work-spec.feature.js",
      "node": "./dist/node/work-spec.feature.js",
      "default": "./dist/work-spec.feature.js"
    },
    "./workspace-revision": {
      "types": "./dist/workspace-revision.d.ts",
      "browser": "./dist/browser/workspace-revision.js",
      "bun": "./dist/workspace-revision.js",
      "node": "./dist/node/workspace-revision.js",
      "default": "./dist/workspace-revision.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:^`
- `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 .",
  "lint:check": "node ../../../../scripts/biome.cjs check .",
  "test": "bun test",
  "prebuild": "contractspec-bun-build prebuild",
  "typecheck": "tsgo --noEmit"
}
```

## Declared documentation links

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

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

## Existing agent-guide projection

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