# @lssm-tech/integration.work-durable-store

PostgreSQL event, idempotency, projection, and outbox adapter for the canonical Work Graph.

## Source and release context

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

## Package metadata

```json
{
  "layer": "integrations",
  "physicalArea": null,
  "primaryArea": "company-and-work",
  "classification": {
    "privateDeclared": null,
    "catalogFamily": "integrations",
    "catalogKind": "integration",
    "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/integrations/work-durable-store/README.md",
  "sourceUrl": "https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/integrations/work-durable-store/README.md",
  "blobSha": "cb3e33759e973fbcd4a7fca13caca17b1b00850e",
  "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/integration.work-durable-store`

PostgreSQL implementation of the canonical Work Graph event, idempotency,
projection, and transactional-outbox ports. It binds every instance to a tenant,
stores immutable events, and ships forced-RLS migration SQL. Command commits do
not update projections; an authorized outbox worker calls `project` after commit.

This is a managed-runtime integration, not a local-default substitute.

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 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.

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

### Integration Work Durable Store

Capability ID: `package.lssm.tech.integration.work.durable.store`

PostgreSQL event, idempotency, projection, and outbox adapter for the canonical Work Graph.

Use cases:

- Adopt postgresql event, idempotency, projection, and outbox adapter for the canonical work graph

Constraints:

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

Other capability declarations:

```json
{
  "status": "active",
  "aliases": [
    "integration",
    "work",
    "durable",
    "store"
  ],
  "pythonEquivalents": [],
  "alternatives": [],
  "relationships": [],
  "resolutionPriority": 50
}
```

Capability imports:

```json
[
  {
    "from": "@lssm-tech/integration.work-durable-store",
    "symbols": []
  },
  {
    "from": "@lssm-tech/integration.work-durable-store/postgres",
    "symbols": []
  },
  {
    "from": "@lssm-tech/integration.work-durable-store/postgres/errors",
    "symbols": []
  },
  {
    "from": "@lssm-tech/integration.work-durable-store/postgres/migrations",
    "symbols": []
  },
  {
    "from": "@lssm-tech/integration.work-durable-store/postgres/work-store",
    "symbols": []
  }
]
```

## Catalogue metadata

```json
{
  "family": "integrations",
  "kind": "integration",
  "status": "active",
  "adoptionMode": "adoptable",
  "stability": "experimental",
  "platforms": [
    "server"
  ],
  "runtimes": [
    "node"
  ],
  "entrypoints": [
    ".",
    "./postgres",
    "./postgres/errors",
    "./postgres/migrations",
    "./postgres/work-store"
  ],
  "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.integration.work.durable.store",
    "from": "@lssm-tech/integration.work-durable-store",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.integration.work.durable.store",
    "from": "@lssm-tech/integration.work-durable-store/postgres",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.integration.work.durable.store",
    "from": "@lssm-tech/integration.work-durable-store/postgres/errors",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.integration.work.durable.store",
    "from": "@lssm-tech/integration.work-durable-store/postgres/migrations",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.integration.work.durable.store",
    "from": "@lssm-tech/integration.work-durable-store/postgres/work-store",
    "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/integration.work-durable-store` — subpath `.`
  - `unconditional`: `./src/index.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/integrations/work-durable-store/src/index.ts); verified source file.

- `@lssm-tech/integration.work-durable-store/postgres` — subpath `./postgres`
  - `unconditional`: `./src/postgres/index.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/integrations/work-durable-store/src/postgres/index.ts); verified source file.

- `@lssm-tech/integration.work-durable-store/postgres/errors` — subpath `./postgres/errors`
  - `unconditional`: `./src/postgres/errors.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/integrations/work-durable-store/src/postgres/errors.ts); verified source file.

- `@lssm-tech/integration.work-durable-store/postgres/migrations` — subpath `./postgres/migrations`
  - `unconditional`: `./src/postgres/migrations.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/integrations/work-durable-store/src/postgres/migrations.ts); verified source file.

- `@lssm-tech/integration.work-durable-store/postgres/scope-validation` — subpath `./postgres/scope-validation`
  - `unconditional`: `./src/postgres/scope-validation.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/integrations/work-durable-store/src/postgres/scope-validation.ts); verified source file.

- `@lssm-tech/integration.work-durable-store/postgres/work-store` — subpath `./postgres/work-store`
  - `unconditional`: `./src/postgres/work-store.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/integrations/work-durable-store/src/postgres/work-store.ts); verified source file.

- `@lssm-tech/integration.work-durable-store/postgres/work-store.fixtures` — subpath `./postgres/work-store.fixtures`
  - `unconditional`: `./src/postgres/work-store.fixtures.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/integrations/work-durable-store/src/postgres/work-store.fixtures.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"
    },
    "./postgres": {
      "types": "./dist/postgres/index.d.ts",
      "browser": "./dist/browser/postgres/index.js",
      "bun": "./dist/postgres/index.js",
      "node": "./dist/node/postgres/index.js",
      "default": "./dist/postgres/index.js"
    },
    "./postgres/errors": {
      "types": "./dist/postgres/errors.d.ts",
      "browser": "./dist/browser/postgres/errors.js",
      "bun": "./dist/postgres/errors.js",
      "node": "./dist/node/postgres/errors.js",
      "default": "./dist/postgres/errors.js"
    },
    "./postgres/migrations": {
      "types": "./dist/postgres/migrations.d.ts",
      "browser": "./dist/browser/postgres/migrations.js",
      "bun": "./dist/postgres/migrations.js",
      "node": "./dist/node/postgres/migrations.js",
      "default": "./dist/postgres/migrations.js"
    },
    "./postgres/scope-validation": {
      "types": "./dist/postgres/scope-validation.d.ts",
      "browser": "./dist/browser/postgres/scope-validation.js",
      "bun": "./dist/postgres/scope-validation.js",
      "node": "./dist/node/postgres/scope-validation.js",
      "default": "./dist/postgres/scope-validation.js"
    },
    "./postgres/work-store": {
      "types": "./dist/postgres/work-store.d.ts",
      "browser": "./dist/browser/postgres/work-store.js",
      "bun": "./dist/postgres/work-store.js",
      "node": "./dist/node/postgres/work-store.js",
      "default": "./dist/postgres/work-store.js"
    },
    "./postgres/work-store.fixtures": {
      "types": "./dist/postgres/work-store.fixtures.d.ts",
      "browser": "./dist/browser/postgres/work-store.fixtures.js",
      "bun": "./dist/postgres/work-store.fixtures.js",
      "node": "./dist/node/postgres/work-store.fixtures.js",
      "default": "./dist/postgres/work-store.fixtures.js"
    }
  }
}
```

## Dependencies

Metadata status: complete pinned manifest.

### Runtime dependencies

- [@lssm-tech/lib.contracts-integrations](https://lssm.co/docs/packages/lib.contracts-integrations/): `workspace:^`
- [@lssm-tech/lib.work-runtime](https://lssm.co/docs/packages/lib.work-runtime/): `workspace:^`
- [@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

- `@electric-sql/pglite`: `catalog:data`
- [@lssm-tech/tool.bun](https://lssm.co/docs/packages/tool.bun/): `workspace:*`
- [@lssm-tech/tool.typescript](https://lssm.co/docs/packages/tool.typescript/): `workspace:*`
- `@types/bun`: `catalog:types`
- `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
{
  "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:check": "node ../../../scripts/biome.cjs check .",
  "lint:fix": "node ../../../scripts/biome.cjs check --write .",
  "test": "bun test",
  "prebuild": "contractspec-bun-build prebuild",
  "typecheck": "tsgo --noEmit"
}
```

## Declared documentation links

- [Integration Work Durable Store documentation](https://www.npmjs.com/package/%40lssm-tech%2Fintegration.work-durable-store) — declared link; destination not verified.

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

## Existing agent-guide projection

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