T-6: Eliminate sandbox git-metadata deadlock for check gates
This commit is contained in:
parent
4a6f75c232
commit
3c7d67fea6
2 changed files with 59 additions and 0 deletions
|
|
@ -6,6 +6,12 @@
|
|||
- Typecheck: `bun run typecheck`
|
||||
- Tests: `bun test` (PostgreSQL safety tests require `PIPELINE_TEST_DATABASE_URL` pointing to a dedicated `stock_bot_safety*` database, configured via `/home/boki/.studio/test-env/stock-bot.env`).
|
||||
|
||||
### Check Gates & Sandbox Split
|
||||
- **Why `bun run check` (`scripts/check.ts`) cannot pass end-to-end inside the agent sandbox**: worktree `.git` metadata lives outside the sandbox (breaking `audit:secrets` and the worktree-git tooling tests in `scripts/test/audit-secrets-repo.test.ts`, `strategy-packaging.test.ts`, `benchmark-research.test.ts`, `benchmark-replay.test.ts`, and `benchmark-sma.test.ts`), and sandbox network isolation blocks host PostgreSQL `127.0.0.1:5432` for `PIPELINE_TEST_DATABASE_URL` suites.
|
||||
- **Sandbox-runnable gates (run locally before handoff)**: `bun run typecheck`, `bun run test:contracts`, `bun run lint:check`, `CARGO_BUILD_JOBS=2 bun run test:native`, `bun run test:utils`, `bun run test:calculations`, and targeted non-git/non-Postgres tests (e.g. `bun test scripts/test/security.test.ts`).
|
||||
- **Studio unsandboxed verification (`bun run build` and `bun --env-file=/home/boki/.studio/test-env/stock-bot.env test`)**: authoritatively covers `build`, `audit:secrets` (via `scripts/test/audit-secrets-repo.test.ts`), `test:tooling` (including all worktree-git tests), `test:integration`, and PostgreSQL-backed tests. Sandbox-only `.git`/PostgreSQL failures are not a review deadlock when Studio's unsandboxed run is green, and agents must never skip or mock out those checks to make them pass inside the sandbox.
|
||||
- **Full host verification outside a sandbox**: run `CARGO_BUILD_JOBS=2 bun run check`.
|
||||
|
||||
## Environments (`dev` / `qa` / `prod`)
|
||||
|
||||
| Environment | `NODE_ENV` | Compose File | PostgreSQL | MongoDB (Write) | MongoDB (Read / Pipeline) | Dragonfly | QuestDB |
|
||||
|
|
|
|||
53
scripts/test/audit-secrets-repo.test.ts
Normal file
53
scripts/test/audit-secrets-repo.test.ts
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
import { mkdtempSync, rmSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { expect, test } from 'bun:test';
|
||||
|
||||
const repoRoot = fileURLToPath(new URL('../../', import.meta.url));
|
||||
const auditScript = fileURLToPath(new URL('../audit-secrets.ts', import.meta.url));
|
||||
|
||||
function isolatedGitEnv(baseEnv: NodeJS.ProcessEnv = process.env): Record<string, string> {
|
||||
const env: Record<string, string> = {};
|
||||
for (const [key, value] of Object.entries(baseEnv)) {
|
||||
if (value !== undefined && !key.startsWith('GIT_')) {
|
||||
env[key] = value;
|
||||
}
|
||||
}
|
||||
return env;
|
||||
}
|
||||
|
||||
function runAuditSecrets(cwd: string, baseEnv: NodeJS.ProcessEnv = process.env) {
|
||||
const result = Bun.spawnSync([process.execPath, auditScript], {
|
||||
cwd,
|
||||
env: isolatedGitEnv(baseEnv),
|
||||
stdout: 'pipe',
|
||||
stderr: 'pipe',
|
||||
});
|
||||
return {
|
||||
exitCode: result.exitCode,
|
||||
stdout: new TextDecoder().decode(result.stdout),
|
||||
stderr: new TextDecoder().decode(result.stderr),
|
||||
};
|
||||
}
|
||||
|
||||
test('audit:secrets passes on the real repository', () => {
|
||||
const result = runAuditSecrets(repoRoot);
|
||||
|
||||
expect(result.exitCode, result.stderr).toBe(0);
|
||||
expect(result.stderr).toBe('');
|
||||
expect(result.stdout).toContain('Secret audit passed');
|
||||
});
|
||||
|
||||
test('audit:secrets fails closed when git metadata is unavailable', () => {
|
||||
const tempDir = mkdtempSync(join(tmpdir(), 'audit-secrets-no-git-'));
|
||||
|
||||
try {
|
||||
const result = runAuditSecrets(tempDir);
|
||||
|
||||
expect(result.exitCode).not.toBe(0);
|
||||
expect(result.stderr).toContain('Cannot inspect tracked files for the secret audit');
|
||||
} finally {
|
||||
rmSync(tempDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue