From 860ca8995cd30fbc460b7e2e688ca7b281c7ce01 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Thu, 26 Mar 2026 21:59:16 -0600 Subject: [PATCH] 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) --- test/gen-skill-docs.test.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/test/gen-skill-docs.test.ts b/test/gen-skill-docs.test.ts index cab12413..55ee4c5f 100644 --- a/test/gen-skill-docs.test.ts +++ b/test/gen-skill-docs.test.ts @@ -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([]); + }); +});