# @lssm-tech/integration.company-intelligence-postgres

Postgres persistence for Company Intelligence canonical records and the durable document evidence ledger.

## Source and release context

- Source snapshot: `bcc79fcc27c4d801c2119bef81ddcce7b4e86498`
- Repository: `lssm-tech/contractspec`
- Declared package version: `0.1.0`
- Package path: `packages/integrations/company-intelligence-postgres`
- Manifest path: `packages/integrations/company-intelligence-postgres/package.json`
- Manifest Git blob: `7d453083a37ea950bc0b90f74d4c3833c0b3b830`
- Manifest origin: pinned GitHub manifest fetch
- Manual: [@lssm-tech/integration.company-intelligence-postgres](https://lssm.co/docs/packages/integration.company-intelligence-postgres/)
- 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/company-intelligence-postgres)
- [Manifest source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/integrations/company-intelligence-postgres/package.json)
- [Readme source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/integrations/company-intelligence-postgres/README.md)
- [Guide source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/apps/web-landing/public/llms-packages/integration.company-intelligence-postgres.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/company-intelligence-postgres/README.md",
  "sourceUrl": "https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/integrations/company-intelligence-postgres/README.md",
  "blobSha": "e4193070e241585749e65331db07977be263cd47",
  "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.company-intelligence-postgres

Postgres persistence owned by Company Intelligence, usable by any host:

- `CompanyIntelligenceRecordRepository` commits validated canonical record packets idempotently (append-only records, references, receipts, outbox event).
- `createCompanyIntelligenceDocumentEvidenceLedgerFromDatabase(database)` returns a durable `DocumentEvidenceLedger` (`@lssm-tech/lib.knowledge/evidence`). Originals and extraction runs live in `managed_companyos_ci_document_originals` / `managed_companyos_ci_document_extractions`; lineage (source → version → asset → part → fragment → evidence) is committed as canonical records, and supersession or withdrawal are append-only tombstones, so every Company Intelligence read path honours them.
- `createCompanyIntelligenceDocumentEvidenceLedgerFromUrl({ connectionString })` returns `undefined` when no connection string is configured, so hosts report the ledger as missing instead of falling back.
- `createCompanyIntelligenceEvidenceVectorStore({ runTenantTx, createStore })` is the tenant-isolated evidence search projection in `managed_companyos_ci_evidence_vectors` (pgvector `vector(1536)` from the `extensions` schema, HNSW cosine index, RLS on `app.tenant_id`). Every upsert, search and delete must carry the owning `tenantId` (knowledge evidence vector tenancy) and runs in that tenant's transaction; the host injects the generic store, e.g. `SupabaseVectorProvider` with `createTableIfMissing: false` and `extensionSchema: 'extensions'`. A missing tenant, a payload owned by another tenant or a vector of another dimension fails closed.

Every operation runs in a transaction with `app.tenant_id` set for forced row-level security. List parameters are JSON-encoded, so the adapter works with any `DatabaseProvider` driver.

The schema is migrated by the Company Intelligence host (`api-application-monolith` migrations 0022–0027, 0099, 0110 and 0180); this package never runs DDL.


## Declared capabilities

### Company Intelligence Postgres

Capability ID: `package.lssm.tech.integration.company.intelligence.postgres`

Commit canonical Company Intelligence record packets and persist durable document evidence (originals, extraction runs, lineage lifecycle) with tenant RLS.

Use cases:

- Durable DocumentEvidenceLedger for any host
- Canonical Company Intelligence record commits

Constraints:

```json
{
  "platforms": [
    "server"
  ],
  "runtimes": [
    "bun",
    "node"
  ],
  "avoidWhen": [
    "The Company Intelligence migrations (0022-0027, 0099, 0110, 0180) are not applied to the target database."
  ],
  "requires": [
    "PostgreSQL",
    "TypeScript"
  ]
}
```

Other capability declarations:

```json
{
  "status": "active",
  "aliases": [
    "company-intelligence",
    "document-evidence",
    "ledger",
    "postgres"
  ],
  "pythonEquivalents": [],
  "alternatives": [],
  "relationships": [],
  "resolutionPriority": 50
}
```

Capability imports:

```json
[
  {
    "from": "@lssm-tech/integration.company-intelligence-postgres",
    "symbols": [
      "createCompanyIntelligenceDocumentEvidenceLedgerFromDatabase",
      "createCompanyIntelligenceDocumentEvidenceLedgerFromUrl",
      "createCompanyIntelligenceEvidenceVectorStore",
      "CompanyIntelligenceRecordRepository"
    ]
  }
]
```

## Catalogue metadata

```json
{
  "family": "integrations",
  "kind": "integration",
  "status": "active",
  "adoptionMode": "adoptable",
  "stability": "experimental",
  "platforms": [
    "server"
  ],
  "runtimes": [
    "bun",
    "node"
  ],
  "entrypoints": [
    "."
  ]
}
```

## 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.company.intelligence.postgres",
    "from": "@lssm-tech/integration.company-intelligence-postgres",
    "symbols": [
      "createCompanyIntelligenceDocumentEvidenceLedgerFromDatabase",
      "createCompanyIntelligenceDocumentEvidenceLedgerFromUrl",
      "createCompanyIntelligenceEvidenceVectorStore",
      "CompanyIntelligenceRecordRepository"
    ]
  }
]
```

## 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.company-intelligence-postgres` — subpath `.`
  - `unconditional`: `./src/index.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/integrations/company-intelligence-postgres/src/index.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",
    "AGENTS.md"
  ],
  "publishExports": {
    ".": {
      "types": "./dist/index.d.ts",
      "bun": "./dist/index.js",
      "node": "./dist/node/index.js",
      "default": "./dist/index.js"
    }
  }
}
```

## Dependencies

Metadata status: complete pinned manifest.

### Runtime dependencies

- [@lssm-tech/integration.provider-database](https://lssm.co/docs/packages/integration.provider-database/): `workspace:^`
- [@lssm-tech/lib.companyos-runtime](https://lssm.co/docs/packages/lib.companyos-runtime/): `workspace:^`
- [@lssm-tech/lib.companyos-spec](https://lssm.co/docs/packages/lib.companyos-spec/): `workspace:^`
- [@lssm-tech/lib.contracts-integrations](https://lssm.co/docs/packages/lib.contracts-integrations/): `workspace:^`
- [@lssm-tech/lib.knowledge](https://lssm.co/docs/packages/lib.knowledge/): `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
{
  "build": "contractspec-bun-build build",
  "build:bundle": "contractspec-bun-build transpile",
  "build:types": "contractspec-bun-build types",
  "lint:check": "node ../../../scripts/biome.cjs check .",
  "test": "bun test",
  "typecheck": "tsgo --noEmit"
}
```

## Declared documentation links

- [Company Intelligence Postgres](https://www.npmjs.com/package/%40lssm-tech%2Fintegration.company-intelligence-postgres) — declared link; destination not verified.

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

## Existing agent-guide projection

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