# @lssm-tech/module.audit-trail

Audit trail module for tracking and querying system events

## Source and release context

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

## Package metadata

```json
{
  "layer": "platform",
  "physicalArea": "governance",
  "primaryArea": "governance-and-approvals",
  "classification": {
    "privateDeclared": null,
    "catalogFamily": "solutions",
    "catalogKind": "module",
    "catalogStatus": "active",
    "adoptionMode": "adoptable",
    "stability": "stable"
  },
  "descriptionOrigin": "package.json",
  "manifestComplete": true,
  "publicationPolicyApplied": false
}
```

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

Primary area: [Governance, decisions and approvals](https://lssm.co/docs/areas/governance-and-approvals/)

## Package guide

```json
{
  "status": "available",
  "sourcePath": "packages/platform/governance/audit-trail/README.md",
  "sourceUrl": "https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/governance/audit-trail/README.md",
  "blobSha": "0b93dd61205deca19c22f3e77d07a98aeac2311b",
  "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/module.audit-trail

Website: https://contractspec.io

**Audit trail module for tracking and querying system events.**

## What It Provides

- **Layer**: module.
- **Consumers**: bundles (library, contractspec-studio), apps (web-landing).
- `src/contracts/` contains contract specs, operations, entities, and registry exports.
- Related ContractSpec packages include `@lssm-tech/lib.bus`, `@lssm-tech/lib.contracts-spec`, `@lssm-tech/lib.schema`, `@lssm-tech/tool.bun`, `@lssm-tech/tool.typescript`.
- `src/contracts/` contains contract specs, operations, entities, and registry exports.

## Installation

`npm install @lssm-tech/module.audit-trail`

or

`bun add @lssm-tech/module.audit-trail`

## Usage

Import the root entrypoint from `@lssm-tech/module.audit-trail`, or choose a documented subpath when you only need one part of the package surface.

For application-facing evidence, use `ScopedAppendOnlyAuditPort` from the
`./storage` subpath. Every append and query requires both `tenantId` and
`workspaceId`; the port deliberately exposes no update, delete, or clear method.
`InMemoryScopedAppendOnlyAuditStore` is the development and contract-test
reference adapter. Administrative retention remains on the legacy storage
adapter and must not be exposed as an application mutation path.

## Architecture

- `src/audit-trail.capability.ts` defines a capability surface.
- `src/audit-trail.feature.ts` defines a feature entrypoint.
- `src/contracts/` contains contract specs, operations, entities, and registry exports.
- `src/entities/` contains domain entities and value objects.
- `src/index.ts` is the root public barrel and package entrypoint.
- `src/storage/` contains persistence adapters and storage implementations.

## Public Entry Points

- Export `.` resolves through `./src/index.ts`.
- Export `./audit-trail.capability` resolves through `./src/audit-trail.capability.ts`.
- Export `./audit-trail.feature` resolves through `./src/audit-trail.feature.ts`.
- Export `./contracts` resolves through `./src/contracts/index.ts`.
- Export `./entities` resolves through `./src/entities/index.ts`.
- Export `./storage` resolves through `./src/storage/index.ts`.

## Local Commands

- `bun run dev` — contractspec-bun-build dev
- `bun run build` — contractspec-bun-build build
- `bun run lint` — bun lint:fix
- `bun run lint:check` — biome check .
- `bun run lint:fix` — biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .
- `bun run typecheck` — tsgo --noEmit
- `bun run publish:pkg` — bun publish --tolerate-republish --ignore-scripts --verbose
- `bun run publish:pkg:canary` — bun publish:pkg --tag canary
- `bun run clean` — rimraf dist .turbo
- `bun run build:bundle` — contractspec-bun-build transpile
- `bun run build:types` — contractspec-bun-build types
- `bun run prebuild` — contractspec-bun-build prebuild

## Recent Updates

- Add strict tenant/workspace-scoped append and query contracts plus an
  append-only reference storage port.
- Replace eslint+prettier by biomejs to optimize speed.

## Notes

- Depends on `lib.bus` for event dispatch -- never emit events outside the bus.
- Audit records are append-only; mutations or deletions break compliance invariants.
- Storage adapters must implement the store interface; do not bypass it.


## Declared capabilities

### Module Audit Trail

Capability ID: `package.lssm.tech.module.audit.trail`

Audit trail module for tracking and querying system events

Use cases:

- Adopt audit trail module for tracking and querying system events

Constraints:

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

Other capability declarations:

```json
{
  "status": "active",
  "aliases": [
    "contractspec",
    "audit",
    "logging",
    "compliance",
    "events",
    "typescript",
    "module",
    "trail"
  ],
  "pythonEquivalents": [],
  "alternatives": [],
  "relationships": [],
  "resolutionPriority": 50
}
```

Capability imports:

```json
[
  {
    "from": "@lssm-tech/module.audit-trail",
    "symbols": []
  },
  {
    "from": "@lssm-tech/module.audit-trail/audit-trail.capability",
    "symbols": []
  },
  {
    "from": "@lssm-tech/module.audit-trail/audit-trail.feature",
    "symbols": []
  },
  {
    "from": "@lssm-tech/module.audit-trail/contracts",
    "symbols": []
  },
  {
    "from": "@lssm-tech/module.audit-trail/contracts/scoped-audit",
    "symbols": []
  },
  {
    "from": "@lssm-tech/module.audit-trail/entities",
    "symbols": []
  },
  {
    "from": "@lssm-tech/module.audit-trail/storage",
    "symbols": []
  },
  {
    "from": "@lssm-tech/module.audit-trail/storage/scoped-append-only",
    "symbols": []
  }
]
```

## Catalogue metadata

```json
{
  "family": "solutions",
  "kind": "module",
  "status": "active",
  "adoptionMode": "adoptable",
  "stability": "stable",
  "platforms": [
    "server"
  ],
  "runtimes": [
    "node"
  ],
  "entrypoints": [
    ".",
    "./audit-trail.capability",
    "./audit-trail.feature",
    "./contracts",
    "./contracts/scoped-audit",
    "./entities",
    "./storage",
    "./storage/scoped-append-only"
  ],
  "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.module.audit.trail",
    "from": "@lssm-tech/module.audit-trail",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.module.audit.trail",
    "from": "@lssm-tech/module.audit-trail/audit-trail.capability",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.module.audit.trail",
    "from": "@lssm-tech/module.audit-trail/audit-trail.feature",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.module.audit.trail",
    "from": "@lssm-tech/module.audit-trail/contracts",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.module.audit.trail",
    "from": "@lssm-tech/module.audit-trail/contracts/scoped-audit",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.module.audit.trail",
    "from": "@lssm-tech/module.audit-trail/entities",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.module.audit.trail",
    "from": "@lssm-tech/module.audit-trail/storage",
    "symbols": []
  },
  {
    "capabilityId": "package.lssm.tech.module.audit.trail",
    "from": "@lssm-tech/module.audit-trail/storage/scoped-append-only",
    "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/module.audit-trail` — subpath `.`
  - `unconditional`: `./src/index.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/governance/audit-trail/src/index.ts); verified source file.

- `@lssm-tech/module.audit-trail/audit-trail.capability` — subpath `./audit-trail.capability`
  - `unconditional`: `./src/audit-trail.capability.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/governance/audit-trail/src/audit-trail.capability.ts); verified source file.

- `@lssm-tech/module.audit-trail/audit-trail.feature` — subpath `./audit-trail.feature`
  - `unconditional`: `./src/audit-trail.feature.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/governance/audit-trail/src/audit-trail.feature.ts); verified source file.

- `@lssm-tech/module.audit-trail/contracts` — subpath `./contracts`
  - `unconditional`: `./src/contracts/index.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/governance/audit-trail/src/contracts/index.ts); verified source file.

- `@lssm-tech/module.audit-trail/contracts/scoped-audit` — subpath `./contracts/scoped-audit`
  - `unconditional`: `./src/contracts/scoped-audit.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/governance/audit-trail/src/contracts/scoped-audit.ts); verified source file.

- `@lssm-tech/module.audit-trail/entities` — subpath `./entities`
  - `unconditional`: `./src/entities/index.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/governance/audit-trail/src/entities/index.ts); verified source file.

- `@lssm-tech/module.audit-trail/storage` — subpath `./storage`
  - `unconditional`: `./src/storage/index.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/governance/audit-trail/src/storage/index.ts); verified source file.

- `@lssm-tech/module.audit-trail/storage/scoped-append-only` — subpath `./storage/scoped-append-only`
  - `unconditional`: `./src/storage/scoped-append-only.ts` — [pinned source](https://github.com/lssm-tech/contractspec/blob/bcc79fcc27c4d801c2119bef81ddcce7b4e86498/packages/platform/governance/audit-trail/src/storage/scoped-append-only.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"
    },
    "./audit-trail.capability": {
      "types": "./dist/audit-trail.capability.d.ts",
      "browser": "./dist/browser/audit-trail.capability.js",
      "bun": "./dist/audit-trail.capability.js",
      "node": "./dist/node/audit-trail.capability.js",
      "default": "./dist/audit-trail.capability.js"
    },
    "./audit-trail.feature": {
      "types": "./dist/audit-trail.feature.d.ts",
      "browser": "./dist/browser/audit-trail.feature.js",
      "bun": "./dist/audit-trail.feature.js",
      "node": "./dist/node/audit-trail.feature.js",
      "default": "./dist/audit-trail.feature.js"
    },
    "./contracts": {
      "types": "./dist/contracts/index.d.ts",
      "browser": "./dist/browser/contracts/index.js",
      "bun": "./dist/contracts/index.js",
      "node": "./dist/node/contracts/index.js",
      "default": "./dist/contracts/index.js"
    },
    "./contracts/scoped-audit": {
      "types": "./dist/contracts/scoped-audit.d.ts",
      "browser": "./dist/browser/contracts/scoped-audit.js",
      "bun": "./dist/contracts/scoped-audit.js",
      "node": "./dist/node/contracts/scoped-audit.js",
      "default": "./dist/contracts/scoped-audit.js"
    },
    "./entities": {
      "types": "./dist/entities/index.d.ts",
      "browser": "./dist/browser/entities/index.js",
      "bun": "./dist/entities/index.js",
      "node": "./dist/node/entities/index.js",
      "default": "./dist/entities/index.js"
    },
    "./storage": {
      "types": "./dist/storage/index.d.ts",
      "browser": "./dist/browser/storage/index.js",
      "bun": "./dist/storage/index.js",
      "node": "./dist/node/storage/index.js",
      "default": "./dist/storage/index.js"
    },
    "./storage/scoped-append-only": {
      "types": "./dist/storage/scoped-append-only.d.ts",
      "browser": "./dist/browser/storage/scoped-append-only.js",
      "bun": "./dist/storage/scoped-append-only.js",
      "node": "./dist/node/storage/scoped-append-only.js",
      "default": "./dist/storage/scoped-append-only.js"
    }
  }
}
```

## Dependencies

Metadata status: complete pinned manifest.

### Runtime dependencies

- [@lssm-tech/lib.bus](https://lssm.co/docs/packages/lib.bus/): `workspace:^`
- [@lssm-tech/lib.contracts-spec-core](https://lssm.co/docs/packages/lib.contracts-spec-core/): `workspace:^`
- [@lssm-tech/lib.schema](https://lssm.co/docs/packages/lib.schema/): `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 --unsafe --only=nursery/useSortedClasses . && node ../../../../scripts/biome.cjs check --write .",
  "lint:check": "node ../../../../scripts/biome.cjs check .",
  "prebuild": "contractspec-bun-build prebuild",
  "typecheck": "tsgo --noEmit"
}
```

## Declared documentation links

- [Module Audit Trail documentation](https://www.npmjs.com/package/%40lssm-tech%2Fmodule.audit-trail) — declared link; destination not verified.

```json
{
  "url": "https://www.npmjs.com/package/%40lssm-tech%2Fmodule.audit-trail",
  "kind": "readme"
}
```

## Existing agent-guide projection

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