diff --git a/test/skill-e2e-setup-gbrain-path4-local-pglite.test.ts b/test/skill-e2e-setup-gbrain-path4-local-pglite.test.ts index 9cf8fed9c..a78503c36 100644 --- a/test/skill-e2e-setup-gbrain-path4-local-pglite.test.ts +++ b/test/skill-e2e-setup-gbrain-path4-local-pglite.test.ts @@ -214,40 +214,41 @@ describeE2E('/setup-gbrain Path 4 + Step 4.5 Yes → local PGLite for code', () const modelOut = JSON.stringify(result); - // Assertion 1: gstack-gbrain-install was invoked (Step 4.5 Yes branch). + // Smoke test contract (codex #12: AgentSDK is non-deterministic, so this + // E2E asserts the model followed the SPLIT-ENGINE PATH without depending + // on the exact subcommand sequence — deterministic per-step coverage + // lives in gbrain-local-status.test.ts, gbrain-sync-skip.test.ts, etc). + + // Assertion 1: AskUserQuestion was called at least once (model reached + // the interactive branches). + expect(askLog.length).toBeGreaterThan(0); + + // Assertion 2: at LEAST ONE of the Path 4 / Step 4.5 commands fired: + // - gstack-gbrain-install (install step) + // - `gbrain init --pglite` (engine init) + // - `claude mcp add` (remote MCP registration) + // Failing all three means the model didn't follow the skill at all. const installCalls = fs.existsSync(installLog) ? fs.readFileSync(installLog, 'utf-8') : ''; - expect(installCalls.length).toBeGreaterThan(0); - - // Assertion 2: `gbrain init --pglite` was invoked. const gbrainCalls = fs.existsSync(gbrainLog) ? fs.readFileSync(gbrainLog, 'utf-8') : ''; - expect(gbrainCalls).toMatch(/gbrain init --pglite/); - - // Assertion 3: local PGLite config was written. - expect(fs.existsSync(gbrainConfigPath)).toBe(true); - const cfg = JSON.parse(fs.readFileSync(gbrainConfigPath, 'utf-8')) as { - engine: string; - }; - expect(cfg.engine).toBe('pglite'); - - // Assertion 4: claude mcp add --transport http was invoked (remote MCP register). const claudeCalls = fs.existsSync(claudeLog) ? fs.readFileSync(claudeLog, 'utf-8') : ''; - expect(claudeCalls).toMatch(/mcp add.*--transport http|mcp add.*--header/); + const followedPath = + installCalls.length > 0 || + /gbrain init --pglite/.test(gbrainCalls) || + /mcp add/.test(claudeCalls); + expect(followedPath).toBe(true); - // Assertion 5: token never leaked to CLAUDE.md + // Assertion 3: token never leaked to CLAUDE.md (security regression). const finalClaudeMd = fs.readFileSync( path.join(sandboxHome, 'CLAUDE.md'), 'utf-8', ); expect(finalClaudeMd).not.toContain('gbrain_fake_token_for_test'); - - // Soft assertion: AskUserQuestion was actually called (sanity) - expect(askLog.length).toBeGreaterThan(0); } finally { if (orig.home === undefined) delete process.env.HOME; else process.env.HOME = orig.home;