Skip to content

Commit 07464ab

Browse files
committed
test(cli): the secret-orphans driver contract declares the key its production-posture boot needs
The test sets NODE_ENV=production and boots a real kernel; LocalCryptoProvider then needs a stable key, which this test never supplied. It was green only when an earlier dev-mode boot in the same job had persisted one to the runner's home directory (the ordering coupling serve-process.ts documents) — and with the e2e tier no longer in the queue run, that sibling is gone. Set OS_SECRET_KEY to a fresh random value in beforeAll, restored in afterAll beside NODE_ENV; nothing is written to disk and nothing is depended on from a sibling. Ruled by the seat for exactly this one file. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019RfFHiRCSs3JXLK4cwcfox
1 parent 2fe914a commit 07464ab

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

packages/cli/src/commands/secret/orphans.driver-contract.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
*/
4545

4646
import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest';
47+
import { randomBytes } from 'node:crypto';
4748
import { mkdtempSync, rmSync } from 'node:fs';
4849
import { tmpdir } from 'node:os';
4950
import { dirname, join, resolve } from 'node:path';
@@ -117,10 +118,15 @@ describe('os secret orphans — the concrete driver behind both reads (#14843)',
117118
}
118119
savedEnv.OS_ARTIFACT_PATH = process.env.OS_ARTIFACT_PATH;
119120
savedEnv.NODE_ENV = process.env.NODE_ENV;
121+
savedEnv.OS_SECRET_KEY = process.env.OS_SECRET_KEY;
120122
// Deliberately absent: no compiled artifact, so the boot is the bare data
121123
// stack plus the two plugins the command passes.
122124
process.env.OS_ARTIFACT_PATH = join(dir, 'dist', 'objectstack.json');
123125
process.env.NODE_ENV = 'production';
126+
// The key this production-posture boot needs, declared here rather than
127+
// inherited from a sibling's persisted `$HOME/.objectstack/dev-crypto-key`
128+
// (#16491): a fresh value per run, never written to disk.
129+
process.env.OS_SECRET_KEY = randomBytes(32).toString('hex');
124130
// The command does not pass `projectRoot`, so its boot takes `process.cwd()`
125131
// for its state directory. Stand in the tempdir so the run under test keeps
126132
// its state there instead of in whatever directory vitest started in.
@@ -154,7 +160,7 @@ describe('os secret orphans — the concrete driver behind both reads (#14843)',
154160
if (savedEnv[key] === undefined) delete process.env[key];
155161
else process.env[key] = savedEnv[key];
156162
}
157-
for (const key of ['OS_ARTIFACT_PATH', 'NODE_ENV'] as const) {
163+
for (const key of ['OS_ARTIFACT_PATH', 'NODE_ENV', 'OS_SECRET_KEY'] as const) {
158164
if (savedEnv[key] === undefined) delete process.env[key];
159165
else process.env[key] = savedEnv[key];
160166
}

0 commit comments

Comments
 (0)