test: regression guard for codex exec inline git rev-parse in -C flag

Scans all .tmpl and resolver .ts source files for codex exec commands
that use inline $(git rev-parse --show-toplevel) in the -C flag. This
pattern causes wrong-project reviews in Conductor workspaces. The test
ensures nobody reintroduces the old pattern.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Garry Tan
2026-03-26 21:59:16 -06:00
parent 4ee8ea9ec9
commit 860ca8995c
+31
View File
@@ -1647,3 +1647,34 @@ describe('telemetry', () => {
}
});
});
describe('codex exec -C must use $_REPO_ROOT, not inline $(git rev-parse)', () => {
// Regression test: inline $(git rev-parse --show-toplevel) in codex exec -C
// evaluates in whatever cwd the background shell inherits, which may be a
// different project in Conductor workspaces. The fix is to resolve _REPO_ROOT
// eagerly at the top of each bash block.
const sourceFiles = [
...fs.readdirSync(ROOT, { recursive: true })
.filter((f): f is string => typeof f === 'string' && f.endsWith('.tmpl') && !f.includes('node_modules')),
'scripts/resolvers/review.ts',
'scripts/resolvers/design.ts',
];
test('no codex exec command uses inline $(git rev-parse --show-toplevel) in -C flag', () => {
const violations: string[] = [];
for (const rel of sourceFiles) {
const abs = path.join(ROOT, rel);
if (!fs.existsSync(abs)) continue;
const content = fs.readFileSync(abs, 'utf-8');
const lines = content.split('\n');
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
if (line.includes('codex exec') && line.includes('-C') && line.includes('$(git rev-parse --show-toplevel)')) {
violations.push(`${rel}:${i + 1}`);
}
}
}
expect(violations).toEqual([]);
});
});