# @lssm-tech/app.communicationos-discord-worker

## Source and release context

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

## Package metadata

```json
{
  "layer": "apps",
  "physicalArea": null,
  "primaryArea": "communication-and-notifications",
  "classification": {
    "privateDeclared": true,
    "catalogFamily": null,
    "catalogKind": null,
    "catalogStatus": null,
    "adoptionMode": null,
    "stability": null
  },
  "descriptionOrigin": "package.json",
  "manifestComplete": true,
  "publicationPolicyApplied": false
}
```

Manifest private flag: true — workspace only.

Primary area: [Communication and notifications](https://lssm.co/docs/areas/communication-and-notifications/)

## Package guide

```json
{
  "status": "available",
  "sourcePath": "packages/apps/communicationos-discord-worker/README.md",
  "sourceUrl": "https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/apps/communicationos-discord-worker/README.md",
  "blobSha": "b2f53fe0c6786bb1c6db0b2e3c418bd75d4d10c8",
  "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.

# CommunicationOS Discord worker

Thin Node.js 24 composition for the observe-only Discord integration. Deploy
the same binary once with `DISCORD_TRUST_ZONE=staff` and a staff bot token, and
once with `DISCORD_TRUST_ZONE=managed-community` and a separate bot token.

Required environment variables:

- `DISCORD_BOT_TOKEN`
- `DISCORD_TENANT_ID`, `DISCORD_WORKSPACE_ID`
- `DISCORD_TRUST_ZONE` (`staff` or `managed-community`)
- `DISCORD_GUILD_PROFILES_JSON`, a non-empty array of objects containing
  `guildId`, `sourceId`, `spaceId`, `connectionId`, `specialtyKeys`,
  `allowedChannelIds`, and `excludedChannelIds`
- `DISCORD_DATABASE_URL`
- `DISCORD_ENCRYPTION_KEY_BASE64` (32-byte AES key encoded as base64)
- `DISCORD_PSEUDONYM_KEY` (separate keyed-HMAC secret for analysis identities)

Optional policy variables are `DISCORD_ALLOWED_CHANNEL_IDS`,
`DISCORD_EXCLUDED_CHANNEL_IDS`, `DISCORD_BACKFILL_DAYS`, and
`DISCORD_AUDIT_RECONCILIATION_DAYS`. `DISCORD_OBSERVATION_SINK_MODULE` can
override the built-in encrypted PostgreSQL sink with a module exporting
`createDiscordObservationSink`; there is no lossy fallback.
Each trust-zone deployment must use a distinct encryption key and key reference.
The database remains mandatory with an external sink because the active
`community_source` and `discord_guild_installation` rows are refreshed before
every live or backfilled raw write. Revoked, unhealthy, mismatched, or newly
excluded guild/channel observations fail closed before payload encryption.

The legacy `DISCORD_ALLOWED_GUILD_IDS`, `DISCORD_SOURCE_ID`,
`DISCORD_SPACE_ID`, `DISCORD_CONNECTION_ID`, `DISCORD_SPECIALTY_KEYS`, and
channel policy variables remain supported only when exactly one guild ID is
configured. Multi-guild deployments fail closed without complete JSON profiles.

`DISCORD_STAFF_ROLE_IDS`, `DISCORD_MODERATOR_ROLE_IDS`, and
`DISCORD_SPECIALTY_KEYS` configure governed analysis. The worker exposes
`GET /health` on `DISCORD_HEALTH_PORT` (default `8083`); degraded and offline
coverage, including startup, returns HTTP 503. `GET /live` reports process
liveness without claiming Gateway readiness.
Railway's `PORT` is used when `DISCORD_HEALTH_PORT` is not set.


## Declared capabilities

This manifest does not declare a capability catalogue. Assess the package using its guide, import map and source.

## 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
[]
```

## 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/app.communicationos-discord-worker` — subpath `.`
  - `unconditional`: `./src/index.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/apps/communicationos-discord-worker/src/index.ts); verified source file.

- `@lssm-tech/app.communicationos-discord-worker/config` — subpath `./config`
  - `unconditional`: `./src/config.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/apps/communicationos-discord-worker/src/config.ts); verified source file.

## Package publication metadata

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

```json
{
  "types": null,
  "files": null,
  "publishExports": null
}
```

## Dependencies

Metadata status: complete pinned manifest.

### Runtime dependencies

- [@lssm-tech/integration.communication-channel-discord](https://lssm.co/docs/packages/integration.communication-channel-discord/): `workspace:^`
- [@lssm-tech/integration.communication-os-persistence](https://lssm.co/docs/packages/integration.communication-os-persistence/): `workspace:^`
- [@lssm-tech/lib.communication-runtime](https://lssm.co/docs/packages/lib.communication-runtime/): `workspace:^`
- [@lssm-tech/module.community-intelligence](https://lssm.co/docs/packages/module.community-intelligence/): `workspace:^`

### Peer dependencies

No declarations in the inspected manifest.

### Optional dependencies

No declarations in the inspected manifest.

### Development dependencies

- [@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": "bun build --target node --packages bundle --outfile dist/server.js src/server.ts",
  "lint:check": "node ../../../scripts/biome.cjs check .",
  "lint:fix": "node ../../../scripts/biome.cjs check --write .",
  "start": "node dist/server.js",
  "dev": "bun run src/server.ts",
  "test": "bun test",
  "typecheck": "tsgo --noEmit"
}
```

## Declared documentation links

No additional documentation links are declared in the inspected catalogue.

## Existing agent-guide projection

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