# L0 completeness probe toolkit

These pack-agnostic scripts probe install, verify, and drift behavior for a
source-backed pack. They do not define or install a second product App.

P1x removed the historical release-shaped issue-tracker pack and its two-pack
CI matrix. The only retained issue-tracker artifact is the sealed selected-root
conformance fixture under `tests/conformance/issue-tracker-runtime/`; that
fixture is deliberately not installable and must not be passed to these tools.

## Prerequisites

- TiDB at `TIDB_HOST:TIDB_PORT` (defaults to `127.0.0.1:4000`).
- A real source-backed pack path or `official_repo:<name>` source.
- `NEXUSCRM_OFFICIAL_APP_PACKS_ROOT` for official packs.
- `SETUP_GO_TAGS=crm` only when the CRM distribution's registered L1
  capabilities are required.

The probes compile a repository-owned, test-only SQL helper from the pinned Go
module. They do not require a host-provided `mysql` client or runner package
installation.

## Probes

`idempotent-and-source-missing.sh` verifies that reinstall is idempotent and
that verification fails closed when its source disappears:

```bash
export NEXUSCRM_OFFICIAL_APP_PACKS_ROOT=/abs/path/to/nexuscrm-app-packs
SETUP_GO_TAGS=crm ./tests/integration/l0-completeness/idempotent-and-source-missing.sh \
  official_repo:salesforce-crm-standard salesforce-crm-standard
```

`admin-override-drift.sh` mutates one locked field and verifies that type,
maximum-length, and `IsCustomized` drift cannot bypass pack ownership:

```bash
SETUP_GO_TAGS=crm ./tests/integration/l0-completeness/admin-override-drift.sh \
  salesforce-crm-standard Account Name
```

Both scripts write machine-readable per-probe JSON under `OUT_DIR`.

## CRM production gate

`crm-source-backed-gate.sh` is the current CI entrypoint. It runs both probes
against the real CRM pack and preserves the focused controlplane integration
tests for fail-closed verify, explicit physical repair, and runtime metadata
recovery. This is a one-product production safety gate, not evidence of L0
multi-App neutrality.

The recovery portion can also run directly against a disposable local TiDB:

```bash
TIDB_HOST=127.0.0.1 TIDB_PORT=4000 TIDB_USER=root \
  bash tests/integration/l0-completeness/controlplane-runtime-recovery.sh
```

It uses the backend's pinned Controlplane version and an isolated copy of its
module files to resolve external-package test-only dependencies. Production
module files stay unchanged. Every named recovery test must actually pass;
skips and missing tests fail the gate. JSON evidence includes compiler/setup
diagnostics as well as test output. Each test creates and drops its own temporary
database, so use a test account with those privileges, never a business database.

## Optional matrix reduction

`reduce-matrix.mjs` combines results from two or more explicitly supplied
packs. It fails closed on missing, unexpected, failed, skipped, or unexecuted
cells. This reducer remains tested as a generic diagnostic primitive, but no
current production CI workflow invents a second installable App merely to feed
it. A future release gate may use it only after a real independently owned App
or an explicitly scoped install-conformance fixture exists.
