# Boundary Ledger

> Generated by `tools/boundarygate` (`go run ./tools/boundarygate -update`).
> This is the machine-checked snapshot of the module boundary; the gate
> (`go run ./tools/boundarygate`) fails CI on any regression beyond the
> baselines recorded under `tools/boundarygate/`.

## Modules

First-party Go modules in the workspace, with non-blank Go LOC (nested
modules excluded from a parent's count).

| Module | Directory | Go LOC | Status |
|---|---|---:|---|
| `github.com/nexuscrm/analytics` | `nexuscrm-analytics` | 31902 | present |
| `github.com/nexuscrm/audit` | `nexuscrm-audit` | 3827 | present |
| `github.com/nexuscrm/auth` | `nexuscrm-auth` | 3617 | present |
| `github.com/nexuscrm/automation` | `nexuscrm-automation` | 90622 | present |
| `github.com/nexuscrm/backend` | `backend` | 42650 | present |
| `github.com/nexuscrm/backend/distributions` | `backend/distributions` | 4812 | present |
| `github.com/nexuscrm/db` | `nexuscrm-db` | 1723 | present |
| `github.com/nexuscrm/dialect-sf-crm` | `nexuscrm-app-packs/dialects/dialect-sf-crm` | 34858 | present |
| `github.com/nexuscrm/dialect-sf-crm-soql` | `nexuscrm-app-packs/dialects/dialect-sf-crm-soql` | 2408 | present |
| `github.com/nexuscrm/events` | `nexuscrm-events` | 2654 | present |
| `github.com/nexuscrm/files` | `nexuscrm-files` | 1384 | present |
| `github.com/nexuscrm/kernel` | `nexuscrm-kernel` | 29961 | present |
| `github.com/nexuscrm/metadata` | `nexuscrm-metadata` | 26600 | present |
| `github.com/nexuscrm/outbound` | `nexuscrm-outbound` | 2601 | present |
| `github.com/nexuscrm/permissions` | `nexuscrm-permissions` | 11610 | present |
| `github.com/nexuscrm/persistence` | `nexuscrm-persistence` | 36472 | present |
| `github.com/nexuscrm/records` | `nexuscrm-records` | 52293 | present |
| `github.com/nexuscrm/shared` | `shared` | 23572 | present |
| `github.com/nexuscrm/storage` | `nexuscrm-storage` | 693 | present |
| `github.com/nexuscrm/worker` | `nexuscrm-worker` | 2682 | present |
| `nexuscrm-tests/sf-crm` | `tests/conformance/sf-crm` | 53 | present |

**Total Go LOC (first-party, present modules): 406994**

## Dependency adjacency (first-party require edges)

Edges are `require` directives among first-party modules (the real build
graph). `replace` directives only rewire resolution and are not edges.

| Module | First-party requires |
|---|---|
| `analytics` | `automation`, `db`, `events`, `kernel`, `metadata`, `permissions`, `persistence`, `shared`, `nexuscrm-contract` |
| `audit` | `kernel`, `shared`, `nexuscrm-contract` |
| `auth` | `kernel`, `shared`, `nexuscrm-contract` |
| `automation` | `analytics`, `audit`, `auth`, `db`, `events`, `kernel`, `metadata`, `outbound`, `permissions`, `persistence`, `records`, `shared`, `nexuscrm-contract` |
| `backend` | `analytics`, `audit`, `auth`, `automation`, `db`, `events`, `files`, `kernel`, `metadata`, `outbound`, `permissions`, `persistence`, `records`, `shared`, `storage`, `nexuscrm-api-host`, `nexuscrm-connectors`, `nexuscrm-contract`, `nexuscrm-controlplane` |
| `backend/distributions` | `analytics`, `audit`, `auth`, `automation`, `backend`, `db`, `dialect-sf-crm`, `dialect-sf-crm-soql`, `events`, `files`, `kernel`, `metadata`, `outbound`, `permissions`, `persistence`, `records`, `shared`, `storage`, `nexuscrm-api-host`, `nexuscrm-connectors`, `nexuscrm-contract`, `nexuscrm-controlplane` |
| `db` | `kernel`, `shared`, `nexuscrm-contract` |
| `dialect-sf-crm` | `dialect-sf-crm-soql`, `shared` |
| `dialect-sf-crm-soql` | `shared` |
| `events` | `db`, `kernel`, `persistence`, `shared`, `nexuscrm-contract` |
| `files` | `automation`, `db`, `events`, `kernel`, `metadata`, `persistence`, `shared`, `storage`, `nexuscrm-contract` |
| `kernel` | `shared`, `nexuscrm-contract` |
| `metadata` | `automation`, `db`, `events`, `kernel`, `persistence`, `shared`, `nexuscrm-contract` |
| `outbound` | `kernel`, `shared`, `nexuscrm-contract` |
| `permissions` | `kernel`, `shared`, `nexuscrm-contract` |
| `persistence` | `db`, `kernel`, `shared`, `nexuscrm-contract` |
| `records` | `analytics`, `audit`, `auth`, `automation`, `db`, `events`, `kernel`, `metadata`, `permissions`, `persistence`, `shared`, `nexuscrm-contract` |
| `shared` | `nexuscrm-contract` |
| `storage` | — |
| `worker` | — |
| `nexuscrm-tests/sf-crm` | `backend`, `shared`, `nexuscrm-contract` |

## Strongly connected components (Tarjan)

Cycles among first-party modules. Accepted components are allowlisted in
`tools/boundarygate/accepted_sccs.txt`; the gate fails on a NEW SCC or a
new member joining an existing one.

| SCC members | Size | Accepted |
|---|---:|---|
| `analytics`, `automation`, `metadata`, `records` | 4 | yes (seeded) |

## Forbidden-edge violations (current)

Policy: `contract` is the sink (no first-party imports); `api-host` must not
depend on backend/controlplane/engine modules; `controlplane` must not
depend on `backend`. Entries below exist today and are baselined in
`tools/boundarygate/forbidden_edge_baseline.txt`.

_No forbidden-edge violations._

## Contract runtime leaks (`database/sql` / `net/http`)

Contract package files that currently import a runtime dependency. The
contract module must stay neutral; this list is baselined in
`tools/boundarygate/contract_runtime_leak_baseline.txt` and PR1 shrinks it
toward empty.

_No contract runtime leaks (baseline empty)._

## L0 dialect-token baseline (per module)

Product-dialect tokens (`salesforce|soql|sosl|sobject|hubspot|opportunity|
tooling`, case-insensitive) found in L0 engine-module source. This freezes
the known dialect leak so it cannot grow; baseline is
`tools/boundarygate/l0_dialect_baseline.txt`.

| L0 module | Files with dialect tokens |
|---|---:|
| `analytics` | 18 |
| `audit` | 8 |
| `auth` | 0 |
| `automation` | 68 |
| `db` | 0 |
| `events` | 2 |
| `files` | 1 |
| `kernel` | 34 |
| `metadata` | 19 |
| `outbound` | 0 |
| `permissions` | 18 |
| `persistence` | 29 |
| `records` | 63 |
| `shared` | 37 |
| `storage` | 0 |
| `worker` | 0 |

**Total L0 dialect-token hit files: 297**

Per-token file counts (a file may match multiple tokens):

| Token | Files |
|---|---:|
| `salesforce` | 119 |
| `soql` | 22 |
| `sosl` | 6 |
| `sobject` | 237 |
| `hubspot` | 0 |
| `opportunity` | 14 |
| `tooling` | 19 |

## How CI runs this

```sh
# From the repo root, in go.work workspace mode (the default).
# Exits non-zero on any NEW (non-baselined) violation.
GOPRIVATE='github.com/pingcap-inc/*,github.com/nexuscrm/*' \
  go run ./tools/boundarygate
```

> The tool is stdlib-only, so it builds with no module downloads; `GOPRIVATE`
> just keeps `go` from contacting a proxy for the private workspace modules.
> Do not pass `-mod=mod` in workspace mode — `go` rejects it.

The tool is its own module (`github.com/nexuscrm/boundarygate`, stdlib only)
so it adds nothing to the backend dependency graph. To intentionally accept
a boundary change (e.g. a deliberately added cycle) and regenerate this
ledger plus the baselines, run `go run ./tools/boundarygate -update`.
