# Checklists

A to-do list, to tick as it is done: the configuration an application adopting db2kit checks or decides. The tests of db2kit on a real subsystem have their own list, in the repository of db2kit (`docs/integration-tests.md`). No value of an environment is written here: they belong to the application and to `.env`.

## Configuration of an application

Each setting is in [configuration.md](configuration.md). The `AGENTS.md` that `npx db2kit generate` writes in the application holds the same settings as a table, each with its value in effect (`(default)` when nobody decided it) and what to decide: run `generate` after each update of db2kit, then go through it. Since 0.10.0, an unknown key or a section that is not an object stops the startup: run the application once after each update of db2kit.

### Startup

- [ ] **`npx db2kit init`**, right after the install and before a code assistant works on the project: the db2kit section of the instruction file, with the rules no assistant may break. `doctor` warns while it is missing or out of date.
- [ ] **One configuration file**: the application reads `db2kit.config.mts` with `loadConfigFile()` (`Db2Module.forRootAsync` with NestJS), never a copy written in its code. The image of production holds the file.
- [ ] **Only seven variables are read** by `connectionFromEnv`: another variable with its prefix (`_READ_ONLY`, a table name) does nothing. Read-only mode is `readOnly: true` in the configuration.
- [ ] **Unknown keys.** Start the application once: a `Db2ConfigError` names every key db2kit does not know, with the right spelling when only the case differs. An object built from a wider configuration (`{ ...appConfig.database }`) brings its other keys with it: pick the keys db2kit takes.
- [ ] **`doctor`.** `npx db2kit doctor`: connection, version, compatibility level, threadpool. The connection string it shows is the one the pool sends, with `RECEIVETIMEOUT`.
- [ ] **`UV_THREADPOOL_SIZE`** at least `pool.max + 2`, set in the environment that starts the process (a warning at startup otherwise).

### Connection

- [ ] **`connectionFromEnv`**: the names of the variables, never their values, in the configuration. A rotated password applies to the next connection, without restart.
- [ ] **Extra keywords** (`connection.extraKeywords`, or the extra keywords variable): only what the subsystem needs (`AUTHENTICATION`, `SECURITY`...). Never `PWD`, `UID`, `RECEIVETIMEOUT` or another keyword db2kit sets: refused at startup.
- [ ] **`cli.envFile`**: the environment file the CLI loads, named once in the configuration.

### Pool and time limits

| Setting                  | Default | To decide                                                                                                                                                                                                |
| :----------------------- | :------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `pool.max`               | none    | [production.md](production.md#3-pool-size): the connections the subsystem accepts for this application, not the requests per second                                                                      |
| `pool.min`               | 0       | 1 in production: the first request after a quiet period does not wait for a login                                                                                                                        |
| `pool.acquireTimeoutMs`  | 5000    | How long a request waits for a free connection. Above `connectTimeoutMs` to get the driver error when the server does not answer, below it to fail fast                                                  |
| `pool.connectTimeoutMs`  | 30000   | How long a login waits                                                                                                                                                                                   |
| `pool.receiveTimeoutMs`  | 60000   | Above the slowest expected statement: a statement slower than it fails with `CONNECTION_LOST` and `NO_REPLY`, never retried. Remove any `ReceiveTimeout` or `QueryTimeout` from the extra keywords first |
| `pool.breakerThreshold`  | 3       | Network failures in a row before Db2 counts as unreachable                                                                                                                                               |
| `transactions.timeoutMs` | 10000   | The longest transaction: locks are held until it ends                                                                                                                                                    |
| `query.defaultMaxRows`   | 1000    | The most rows a read returns without an explicit `maxRows`                                                                                                                                               |
| `query.retryLostReads`   | true    | One retry of a pure read whose connection was lost, never after `NO_REPLY`                                                                                                                               |

- [ ] Every row of the table decided, and written in the configuration when it differs from the default.

### Audit and personal data

- [ ] **`audit.params`** stays `'types'` (the default) when the data holds personal data: `'full'` writes the values to the logs.
- [ ] **`audit.applicationName`**: the name the DBA sees in `DISPLAY THREAD` (`CLIENT_APPLNAME`).
- [ ] **`audit.sinks`**: `consoleSink({ only: 'slow-and-errors' })` in production, a JSONL or statistics sink if the fingerprints are reviewed with the DBA.
- [ ] **`audit.refusals`**: `true` to count the calls of the object API that db2kit refused (index guard, wrong argument) in the sinks, for instance in development or during a migration.
- [ ] **Retention**: `retentionDays` of `jsonlSink`, and the retention of the platform that receives the console logs, decided with the data protection officer: 30 days suggested for events without values, 7 days at most with `audit.params: 'full'` ([audit.md](audit.md#retention)).
- [ ] **Cassettes** of `db2kit/testing`: every input and output that identifies a person masked with `procedureMask`, or scenarios run with invented people only ([testing.md](testing.md#recording-and-replay)).

### Reads, writes and procedures

- [ ] **`readOnly: true`** for a service that only reads.
- [ ] **`models.writable`**: the tables written through the object API, one by one. Empty by default.
- [ ] **`models.indexGuard`**: `'throw'` (default) in development.
- [ ] **Outcome rules** of the procedures that modify data: written, then `validated: true` once checked with the team that owns the program. `npx db2kit check` lists those not validated.
- [ ] **Every procedure called through its rule**, the `...WithOutcome` export of its `.outcome.ts` (since 0.30.0 `db.call` refuses the descriptor alone). Each call through `unchecked(descriptor, reason)` reviewed before a release: `npx db2kit check` lists them with their reason, and none remains on a procedure that modifies data outside a test.
- [ ] **`procedures.defaultInputs`**, `fieldStatus`: the conventions of the application, never hard-coded in db2kit. The success values of each procedure live in its outcome rule, written by `probe`.
