Commit 2df621a
fix(verify): os verify never creates key material in the key home; the harness seals under an in-process data key (#21507)
Fixes #21499
Clause-②: no
## What changed
`bootStack` (`packages/verify/src/harness.ts`) composed the settings
service with no crypto provider and bound the engine to a bare
`LocalCryptoProvider`. `bootStack` forces a development posture, where
both providers resolve a data key the way a server does: an env key,
then the key file in the key home, and with neither they mint the key
file. So `os verify`, a one-shot command over an in-memory database,
left key material in the key home. On a host that already had a key, the
harness sealed its throwaway fixtures under that real key.
The harness now holds ONE `LocalCryptoProvider` over an explicit random
key (`harnessCryptoProvider`, module-private):
- no env read, no key-file read, no write anywhere: the key never leaves
the process's memory;
- the settings service (`new SettingsServicePlugin({ cryptoProvider })`)
and the engine (`setCryptoProvider`) get the same instance, so `secret`
fields and encrypted settings still seal AND open on a keyless host.
That is why the CLI's one-shot shape from PR #21497 ("read an existing
key, or refuse every call") does not fit here;
- one key per PROCESS, not per boot: two boots over one `databaseFile`
(the harness's restart) open each other's secrets, as a real host's
stable key would let them.
## Shape choices, measured (dispatch zone 2)
- **A1, confirmed at base `6f17d1d364`.** `harness.ts:498` was `new
SettingsServicePlugin()` with no provider, and `:694` was
`engine.setCryptoProvider(new LocalCryptoProvider())`.
`packages/cli/src/commands/verify.ts:195` and `:219` call
`bootStack(config, { multiTenant })` and `bootStack(config, {
multiTenant, security })`. `BootOptions` has no crypto option.
- **A2: no public option is needed.** No caller of `bootStack` in this
repository passes or needs a key: every boot is an in-memory database or
a caller-owned temp file. So the harness owns its provider internally.
`BootOptions` and every export are unchanged, `Clause-②: no` holds, and
`packages/cli/src/commands/verify.ts` is untouched.
- **Per process, not per boot.** Measured by ablation (below): a
per-boot key breaks the restart case with an AES-GCM authentication
failure.
## Evidence
**Public door.** Built CLI, `examples/app-todo`, `os verify --json`,
development posture, no env key, a fresh empty key home (`OS_HOME`):
| `@objectstack/verify` built from | exit | stdout | key home after |
stderr line announcing a minted key |
|---|---|---|---|---|
| the base harness (`6f17d1d364`, rebuilt; dist preflight: marker
absent) | 1 | 764 B | `dev-crypto-key` | 1 |
| this PR (rebuilt; dist preflight: marker present) | 1 | 764 B,
byte-identical | empty | 0 |
Both runs exit 1 on the same pre-existing fidelity gap on
`todo_task.tags` (see Acceptance notes). It is unrelated to this change.
**Pin** `packages/verify/src/harness.key-custody.test.ts`. Every boot
runs in a hook, and the cases only assert.
- Committed red first (`465c22036a`), against the unfixed harness: 4
failed, 3 passed.
- The empty key home gained `dev-crypto-key`.
- Both sealed rows opened under a pre-existing key file's key: `[true,
true]`.
- Both sealed rows opened under `OS_SECRET_KEY`: `[true, true]`.
- The restart case's key home gained `dev-crypto-key`.
- The control stayed green: the default provider reports
`generated-file` in this posture and home.
- With the change (`7c3a1843ce`): 7 passed.
- Ablation, a per-boot key in place of the per-process one, through
`scripts/ablation-replace.mjs`:
- the anchor went 1 to 0 and the blob changed;
- after the restore, the blob equals HEAD and `git diff HEAD` is empty;
- the restart describe's hook fails with `Unsupported state or unable to
authenticate data` (6 passed, 1 skipped, file red).
- The pin imports `./harness.js` from source, so no `dist/` leg applies
to it.
**Local runs at HEAD `e8a091457c`:**
- `pnpm --filter @objectstack/verify exec vitest run`: 17 files, 127
tests passed.
- `pnpm --filter @objectstack/verify typecheck`: exit 0, tsc plus the
test layer. `--listFiles` on the test config holds the new test (17 of
17 test files).
- `node scripts/pm/dispatch-gates.mjs --commands`: 62 families derived
and all 62 run. The `--ran` reconciliation reads 0 NOT-MEASURED and 0
UNRUN.
- `check:dual-build-cjs-loads` first exited 3 (PREREQUISITE NOT MET: 9
packages had no `dist/`). After a cache-replay build of those 9 it
exited 0.
- `pnpm lint` over the whole repository, unnarrowed: exit 0.
Not run locally: CI's full suites, and the CLI integration tier (no
`packages/cli` file is touched).
## Serial note
PR #21497 adds an enumeration pin over `packages/cli/src`. It had not
landed when this PR was opened, and this branch sits on `6f17d1d364`.
This diff touches no `packages/cli` file, so that pin's population is
unchanged. The seat merges `main` and re-runs that pin at landing.
## Acceptance notes
- `os verify --json` on `examples/app-todo` exits 1 on `main` with one
fidelity gap. The derived write puts the scalar `important` into
`todo_task.tags`, a `select` with `multiple: true`, and reads back the
array `["important"]`. It is reported to the seat as a finding and is
not touched here.
- Every `bootStack` under vitest also stops minting into the runner's
key home. The harness forces a development posture, so the old default
minted there too.
---
_Generated by [Claude
Code](https://claude.ai/code/session_016GiHYRmLSNWTfbX9gVQkpz)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent c205b6c commit 2df621a
3 files changed
Lines changed: 411 additions & 5 deletions
File tree
- .changeset
- packages/verify/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
0 commit comments