Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix: post-upgrade names the setup command for gbrain setup codex's hooks instead of rewriting them (#8424)
garrytand8314fac3bff
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex a02fb809dd..7f4c7f65e4 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -14,7 +14,7 @@ identifiers and attribution are available in the pre-removal Git revision**Security: gbrain's hooks no longer let the session directory's bunfig.toml or .env run (#8424).** A script-mode install (`bun install -g`, `bun link`) runs gbrain as a Bun script, and Bun applies the working directory's `bunfig.toml` (a top-level `preload` runs before any gbrain code) and loads its `.env` files first. Claude Code and Codex run hooks in the session's directory, so with the hooks `gbrain setup claude-code|codex` writes, or the per-turn rule hook from `--instructions-only`, `gbrain connect --install` and `gbrain bootstrap harness`, opening a session in a cloned repository ran that repository's code as you on every prompt, with nothing to approve. Each of those hooks now starts gbrain through `<gbrain config dir>/hook-launcher/gbrain-hook`, a small sh script that records the session directory in `GBRAIN_HOOK_CWD`, changes into its own directory and starts gbrain there. Its directory holds only the launcher, and it refuses to start gbrain if anything else appears there.-- `gbrain post-upgrade` moves existing hooks onto the launcher. That covers the turn-rule hook in Claude Code's user settings and in Codex's hooks.json, and the hooks of each user-scope `gbrain setup` install whose MCP entry is unchanged. A Codex hook moves only when Codex already runs it, so an upgrade never trusts a hook you did not approve, and a hook you edited after setup wrote it is kept and named instead. `gbrain setup <harness>` and `gbrain setup <harness> --instructions-only` rewrite them on their next run.+- `gbrain post-upgrade` moves existing hooks onto the launcher. That covers the turn-rule hook in Claude Code's user settings and in Codex's hooks.json, and the hooks of each user-scope `gbrain setup claude-code` install whose MCP entry is unchanged. A Codex turn-rule hook moves only when Codex already runs it, so an upgrade never trusts a hook you did not approve, and a hook you edited after setup wrote it is kept and named instead. `gbrain setup codex`'s hooks are not moved by an upgrade: rewriting them re-trusts them, so post-upgrade prints the `gbrain setup codex` command that does it, and doctor keeps flagging them until it runs. `gbrain setup <harness>` and `gbrain setup <harness> --instructions-only` rewrite them on their next run.- `gbrain doctor` (`harness_wiring`) warns with the new code `hook_session_cwd` when a hook still starts gbrain in the session directory, or its launcher is missing, changed or shares its directory with a file gbrain did not write, and names the setup command that fixes it. Project-scope installs get the command to run from their project directory.- Not covered yet: the stdio MCP server `gbrain setup` registers, which the harness also starts in the session's directory (#8426); the capture hooks from `gbrain bootstrap`'s own lanes and the gbrain plugins' hooks (#8428); and script-mode commands you run by hand in an untrusted checkout (SECURITY.md).- The launcher rewrite never leaves a temp file in its own directory, and doctor finds a setup hook whose `_gbrain` marker Claude Code dropped by its receipt hash.diff --git a/SECURITY.md b/SECURITY.mdindex b08379520d..cedcebba08 100644--- a/SECURITY.md+++ b/SECURITY.md@@ -93,7 +93,9 @@ changes into its own directory and starts gbrain there, so Bun never reads thesession directory's `bunfig.toml` or `.env`. Its directory holds only thelauncher; if anything else appears there, the launcher refuses to start gbrainand prints one line to stderr. `gbrain post-upgrade` moves hooks written-before the launcher onto it, `gbrain setup` rewrites them on its next run, and+before the launcher onto it (for `gbrain setup codex`'s hooks it prints the+setup command instead, since that rewrite re-trusts them), `gbrain setup`+rewrites them on its next run, and`gbrain doctor` (`harness_wiring`, code `hook_session_cwd`) flags any that areleft. Not covered yet: the stdio MCP server `gbrain setup` registers, whichthe harness also starts in the session's directory (#8426), and the hooks fromdiff --git a/docs/guides/repair.md b/docs/guides/repair.mdindex a2564378fd..d70e6e0b1f 100644--- a/docs/guides/repair.md+++ b/docs/guides/repair.md@@ -4364,7 +4364,9 @@ directory in `GBRAIN_HOOK_CWD` and runs gbrain from its own directory. TheRun `fix.argv` (`gbrain setup <harness>` for setup's hooks,`gbrain setup <harness> --instructions-only` for the turn-rule hook);-`gbrain post-upgrade` moves every user-scope hook it can find. A project-scope+`gbrain post-upgrade` moves every user-scope hook it can find except+`gbrain setup codex`'s, which only setup rewrites because the rewrite re-trusts+them; post-upgrade prints that command instead. A project-scopeinstall is refreshed from its project directory. A setup hook you edited aftersetup wrote it (`edited: true`) is never rewritten, so the fix is a`user_message`: remove or rewrite that entry, then run setup. When the checkdiff --git a/src/commands/doctor/checks/harness-wiring.ts b/src/commands/doctor/checks/harness-wiring.tsindex 4c75feb9bd..3837c7178a 100644--- a/src/commands/doctor/checks/harness-wiring.ts+++ b/src/commands/doctor/checks/harness-wiring.ts@@ -520,7 +520,7 @@ export function hookLauncherFix(p: HookLauncherProblem): Action {const project = p.harness === 'claude-code' && p.source !== claudeUserSettingsPath() ? dirname(dirname(p.source)) : null;const record = p.lane === 'setup' ? localSetupRecords().find((r) => r.harness === p.harness && r.status === 'installed' && (project ? r.projectDir === project : r.scope !== 'project')) : undefined;const argv = ['gbrain', 'setup', p.harness, ...(p.lane === 'turn-rule' ? ['--instructions-only'] : []), ...(record && record.name !== 'gbrain' ? ['--name', record.name] : []), ...(project ? ['--scope', 'project'] : [])];- const why = "Rewrites gbrain's hooks to start gbrain from its own launcher directory, so a repository's bunfig.toml or .env never runs when a session opens there. `gbrain post-upgrade` refreshes the user-scope hooks too.";+ const why = "Rewrites gbrain's hooks to start gbrain from its own launcher directory, so a repository's bunfig.toml or .env never runs when a session opens there. `gbrain post-upgrade` refreshes the user-scope hooks too, except `gbrain setup codex`'s.";const verify = doctorVerify(NAME);if (p.reason === 'foreign') return { consent: [], actor: 'user', requires_exclusive: false, verify, why, user_message: `${p.detail}. Remove that file (gbrain did not write it), then run: ${argv.join(' ')}` };if (p.edited) return { consent: [], actor: 'user', requires_exclusive: false, verify, why, user_message: `${p.detail}. Remove or rewrite that entry in ${p.source} (setup never overwrites an edit), then ${project ? `from ${project}, ` : ''}run: ${argv.join(' ')}` };diff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.tsindex c3d20c4f28..d82b345054 100644--- a/src/core/behavior-change-notice.ts+++ b/src/core/behavior-change-notice.ts@@ -1407,7 +1407,7 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText;// #8384 (GBRA-269) quote fence follow-ups 3. since stamped at the merge slot.{ since: '0.60.541.0', id: 'remote_quotes_followups_8384b', text: 'Agents connected over MCP now get a quoted page\'s title quoted on search, query, assemble_evidence and recall rows, its tags quoted on get_page, fetch and get_tags (add_tag and remove_tag take a copied tag without the fence), and a chronicle row\'s kind quoted by its event page\'s tier; a context_pack card below "your notes" carries its title under the card\'s trust label. A remote put_page of a whole-markdown read saved with CRLF line endings stores the page, not its fence, and a fenced value pasted into frontmatter leaves the other keys as sent. Facts from a quarantined page, or awaiting re-derivation after a purge, no longer appear in entity-fact reads, local ones included: recall, search and query entity facts, find_trajectory, the entity card\'s fact count and consolidate; standing-question evidence also skips such facts, takes and timeline entries. Other local reads are unchanged.' },// #8424 (GBRA-277) hook launcher. since stamped at the merge slot.- { since: '0.60.547.0', id: 'hook_launcher_8424', text: 'The hooks `gbrain setup claude-code|codex` writes, and the per-turn rule hook from `--instructions-only`, `gbrain connect --install` and `gbrain bootstrap harness`, now start gbrain through `<gbrain config dir>/hook-launcher/gbrain-hook`, so a session opened in a cloned repository never runs that repository\'s bunfig.toml preload or loads its .env. `gbrain post-upgrade` moves existing hooks onto it, and doctor `harness_wiring` warns with `hook_session_cwd` on any that still start gbrain in the session directory.' },+ { since: '0.60.547.0', id: 'hook_launcher_8424', text: 'The hooks `gbrain setup claude-code|codex` writes, and the per-turn rule hook from `--instructions-only`, `gbrain connect --install` and `gbrain bootstrap harness`, now start gbrain through `<gbrain config dir>/hook-launcher/gbrain-hook`, so a session opened in a cloned repository never runs that repository\'s bunfig.toml preload or loads its .env. `gbrain post-upgrade` moves existing hooks onto it, except `gbrain setup codex`\'s, which the next `gbrain setup codex` rewrites, and doctor `harness_wiring` warns with `hook_session_cwd` on any that still start gbrain in the session directory.' },];/** The newest disclosed change's release: the notice id moves only when a release adds rows. */diff --git a/src/core/bootstrap/codex-hooks.ts b/src/core/bootstrap/codex-hooks.tsindex 383924c4d2..c0e2b7fc16 100644--- a/src/core/bootstrap/codex-hooks.ts+++ b/src/core/bootstrap/codex-hooks.ts@@ -443,24 +443,14 @@ export function codexHookCensus(hooksPath: string): CodexHookCensusGroup[] {*/export function codexHookGroupRuns(hooksPath: string, configPath: string, group: { event: string; index: number }): boolean {if (group.event !== 'SessionStart' && group.event !== 'UserPromptSubmit') return false;- return groupHandlerRuns(hooksPath, configPath, group.event, group.index, (c) => c.includes(CODEX_SETUP_LANE_TOKEN) || CONTEXT_LANE_TOKENS.some((t) => c.includes(t)));-}--/** codexHookGroupRuns for setup's own groups, SessionEnd's capture group included (its handler carries setup's lane token). */-export function codexSetupGroupRuns(hooksPath: string, configPath: string, group: { event: string; index: number }): boolean {- if (group.event !== 'SessionEnd') return codexHookGroupRuns(hooksPath, configPath, group);- return groupHandlerRuns(hooksPath, configPath, 'SessionEnd', group.index, (c) => c.includes(CODEX_SETUP_LANE_TOKEN));-}--function groupHandlerRuns(hooksPath: string, configPath: string, event: CodexSetupEvent, index: number, accepts: (command: string) => boolean): boolean {- const { stateName } = SETUP_EVENT_SPECS[event];- const handlers = loadHooksJson(hooksPath).hooks[event]?.[index]?.hooks;+ const { stateName } = SETUP_EVENT_SPECS[group.event];+ const handlers = loadHooksJson(hooksPath).hooks[group.event]?.[group.index]?.hooks;if (!Array.isArray(handlers)) return false;const states = readCodexTomlTable(configPath, ['hooks', 'state']) as Record<string, { enabled?: unknown; trusted_hash?: unknown } | undefined> | undefined;return handlers.some((h, i) => {const command = h?.command;- if (typeof command !== 'string' || !accepts(command)) return false;- const state = states?.[`${hooksPath}:${stateName}:${index}:${i}`];+ if (typeof command !== 'string' || !(command.includes(CODEX_SETUP_LANE_TOKEN) || CONTEXT_LANE_TOKENS.some((t) => command.includes(t)))) return false;+ const state = states?.[`${hooksPath}:${stateName}:${group.index}:${i}`];if (!state || state.enabled === false) return false;return state.trusted_hash === codexHookTrustHash(stateName, command, typeof h.timeout === 'number' ? Math.max(1, h.timeout) : 600);});diff --git a/src/core/setup/codex.ts b/src/core/setup/codex.tsindex cb6f3861ac..0d632f1a61 100644--- a/src/core/setup/codex.ts+++ b/src/core/setup/codex.ts@@ -233,7 +233,7 @@ export interface CodexApplyResult { steps: CodexSetupStep[]; receipt: CodexSetupexport async function applyCodexSetup(plan: CodexSetupPlan,consent: SetupConsent,- opts: { pluginOwner: string | null; brainCreated: boolean; beforeMcp?: () => Promise<void>; abortAfter?: string; mcpMustBeCurrent?: boolean },+ opts: { pluginOwner: string | null; brainCreated: boolean; beforeMcp?: () => Promise<void>; abortAfter?: string },): Promise<CodexApplyResult> {const paths = codexSetupPaths(plan.name);mkdirSync(dirname(paths.configPath), { recursive: true, mode: 0o700 });@@ -242,7 +242,6 @@ export async function applyCodexSetup(// Every hook command starts gbrain through the launcher, so it goes down before anything names it (#8424).if (plan.events.length) ensureHookLauncher(hookLauncherPath(plan.brainHome));const found = inspectCodexSetup(plan);- if (opts.mcpMustBeCurrent && opts.pluginOwner === null && found.mcp.state !== 'current') throw new Error(`the '${plan.name}' MCP entry changed before the hooks were rewritten`);const prior = found.prior;const now = new Date().toISOString();const desired = desiredCodexMcpEntry(plan);diff --git a/src/core/setup/hook-launcher-refresh.ts b/src/core/setup/hook-launcher-refresh.tsindex 03b29fac2b..a4e28a120c 100644--- a/src/core/setup/hook-launcher-refresh.ts+++ b/src/core/setup/hook-launcher-refresh.ts@@ -7,23 +7,22 @@* Only gbrain's own entries move, through the writers that own them:* - the turn-rule lane (Claude Code user settings, Codex hooks.json):* syncTurnRuleHook with the binary and GBRAIN_HOME its old command names;- * - each installed \`gbrain setup\` receipt of this install: the same apply- * setup runs, with the plan the receipt records, and only when the MCP- * entry is still exactly setup's (so the apply rewrites hooks, trust and- * the receipt, nothing else). Anything else gets a line naming the- * command that fixes it.+ * - each installed Claude Code \`gbrain setup\` receipt of this install: the+ * same apply setup runs, with the plan the receipt records, and only when+ * the MCP entry is still exactly setup's (so the apply rewrites hooks and+ * the receipt, nothing else). Codex setup installs, and anything else, get+ * a line naming the command that fixes it.* Project-scope setup installs are listed, never rewritten: setup writes those* from the project directory. Best-effort; never throws.*/import { readFileSync } from 'node:fs';import { configDir } from '../config.ts';import { hookEntryHash, parseClaudeHookCommand } from '../bootstrap/hooks.ts';-import { codexHookCensus, codexHookGroupRuns, codexSetupGroupRuns, type CodexHookCensusGroup } from '../bootstrap/codex-hooks.ts';+import { codexHookCensus, codexHookGroupRuns, type CodexHookCensusGroup } from '../bootstrap/codex-hooks.ts';import { join } from 'node:path';import { GBRAIN_HOOK_MARKER_KEY, GBRAIN_SETUP_MARKER_VALUE, claudeUserSettingsPath, codexConfigPath, codexHooksPath, type ClaudeHookEvent } from '../bootstrap/host-specs.ts';-import type { CodexSetupEvent } from '../bootstrap/codex-hooks.ts';import { applyClaudeSetup, claudeSetupPaths, inspectClaudeSetup, readSetupReceipt, type ClaudeSetupPlan } from './claude-code.ts';-import { applyCodexSetup, codexSetupPaths, inspectCodexSetup, readCodexSetupReceipt, type CodexSetupPlan } from './codex.ts';+import { codexSetupPaths, readCodexSetupReceipt } from './codex.ts';import { hookLauncherInCommand, hookLauncherPath, hookLauncherState, shellWords } from './hook-launcher.ts';import { localSetupRecords } from './local-receipts.ts';import { hasTurnRuleHook, isTurnRuleEntry, syncTurnRuleHook, TURN_RULE_LANE_TOKEN } from './turn-hook.ts';@@ -105,21 +104,9 @@ async function refreshSetup(log: (line: string) => void): Promise<void> {const receipt = readCodexSetupReceipt(record.path).setup;if (!receipt) continue;const paths = codexSetupPaths(receipt.name);- const groups = codexHookCensus(paths.hooksPath).filter((g) => g.lane === 'setup');- if (!groups.flatMap((g) => g.commands).some(needsLauncher)) continue;- const plan: CodexSetupPlan = { name: receipt.name, launcher: receipt.launcher, brainHome: receipt.gbrain_home, ...(receipt.gbrain_home_env ? { gbrainHomeEnv: receipt.gbrain_home_env } : {}),- sourceId: receipt.source_id, surface: receipt.surface, advertise: receipt.advertise ?? null, events: Object.keys({ ...receipt.hooks.owned, ...receipt.hooks.pending }) as CodexSetupEvent[] };- // Rewriting re-trusts every setup group, so it runs only when Codex already runs each one: an untrusted, disabled or missing group keeps Codex's approval gate.- const runs = (g: CodexHookCensusGroup) => codexSetupGroupRuns(paths.hooksPath, paths.configPath, g);- const idle = [...new Set([...plan.events.filter((e) => !groups.some((g) => g.event === e && runs(g))), ...groups.filter((g) => !runs(g)).map((g) => g.event)])];- if (idle.length > 0) { log(`Hook launcher: Codex does not run gbrain setup's codex ${idle.join(', ')} hook in ${paths.hooksPath} (not trusted, disabled or removed), so setup's codex hooks are left as is; run ${rerun} to rewrite them.`); continue; }- if (!receipt.mcp_plugin && inspectCodexSetup(plan).mcp.state !== 'current') { log(`Hook launcher: gbrain's codex hooks start gbrain in the session's directory; run ${rerun} to rewrite them.`); continue; }- const applied = await applyCodexSetup(plan, receipt.consent, { pluginOwner: receipt.mcp_plugin ?? null, brainCreated: false, mcpMustBeCurrent: true });- const left = new Set(codexHookCensus(paths.hooksPath).filter((g) => g.commands.some(needsLauncher)).map((g) => g.hash));- const kept = Object.entries(applied.receipt.hooks.edited).filter(([, hash]) => left.has(hash)).map(([event]) => event);- log(kept.length > 0- ? `Hook launcher: gbrain setup's codex ${kept.join(', ')} hook in ${paths.hooksPath} was edited after setup wrote it, so it is kept as is and still starts gbrain in the session's directory; remove or rewrite it, then run ${rerun}.`- : `Hook launcher: gbrain setup's codex hooks in ${paths.hooksPath} now start gbrain from its own directory.`);+ if (!codexHookCensus(paths.hooksPath).some((g) => g.lane === 'setup' && g.commands.some(needsLauncher))) continue;+ // Rewriting re-trusts setup's groups, and a hooks.json every install shares cannot show which install's group Codex runs, so the rewrite stays with setup, where the user approves it.+ log(`Hook launcher: gbrain setup's codex hooks in ${paths.hooksPath} start gbrain in the session's directory; run ${rerun} to rewrite them.`);}} catch (e) {log(`Hook launcher: gbrain's ${record.harness} hooks were not refreshed (${(e as Error).message}); run ${rerun}.`);diff --git a/test/hook-launcher-bunfig.test.ts b/test/hook-launcher-bunfig.test.tsindex 0ae236e631..e15709118d 100644--- a/test/hook-launcher-bunfig.test.ts+++ b/test/hook-launcher-bunfig.test.ts@@ -13,7 +13,7 @@ import { tmpdir } from 'node:os';import { dirname, join, resolve } from 'node:path';import { withEnv } from './helpers/with-env.ts';import { buildClaudeHookCommand } from '../src/core/bootstrap/hooks.ts';-import { codexHookGroupRuns, codexHookTrustHash, codexSetupGroupRuns, codexSetupHookGroup, codexSetupTrustEntry } from '../src/core/bootstrap/codex-hooks.ts';+import { codexHookGroupRuns, codexHookTrustHash, codexSetupHookGroup } from '../src/core/bootstrap/codex-hooks.ts';import { appendCodexTomlTable } from '../src/core/bootstrap/codex-toml.ts';import { captureHookSessionCwd, hookSessionCwd } from '../src/core/setup/hook-launcher.ts';import { syncTurnRuleHook, TURN_RULE_MARKER } from '../src/core/setup/turn-hook.ts';@@ -243,21 +243,6 @@ describe('hooks written before the launcher: doctor flags them, post-upgrade movexpect(codexHookGroupRuns(hooks, config, { event: 'UserPromptSubmit', index: 0 })).toBe(false);});- test("codex: setup's SessionEnd capture group runs only with its own trust entry", () => {- const b = box();- const hooks = join(b.home, '.codex', 'hooks.json');- const config = join(b.home, '.codex', 'config.toml');- const group = codexSetupHookGroup(b.gbrain, 'SessionEnd', {}, 'setup');- mkdirSync(dirname(hooks), { recursive: true });- writeFileSync(hooks, JSON.stringify({ hooks: { SessionEnd: [group] } }));- writeFileSync(config, '');- expect(codexSetupGroupRuns(hooks, config, { event: 'SessionEnd', index: 0 })).toBe(false);- const { key, trusted_hash } = codexSetupTrustEntry(hooks, 'SessionEnd', 0, group);- appendCodexTomlTable(config, ['hooks', 'state', key], { trusted_hash }, 'test: Codex trusted the capture hook');- expect(codexSetupGroupRuns(hooks, config, { event: 'SessionEnd', index: 0 })).toBe(true);- expect(codexHookGroupRuns(hooks, config, { event: 'SessionEnd', index: 0 })).toBe(false);- });-test('the recorded session directory is resolved and dropped from the environment', async () => {const b = box();const link = join(b.root, 'link-to-checkout');diff --git a/test/setup.test.ts b/test/setup.test.tsindex 40e869f345..d27b4e0f9a 100644--- a/test/setup.test.ts+++ b/test/setup.test.ts@@ -1002,22 +1002,31 @@ describe('hooks written before the hook launcher (#8424): the next setup and posawait withEnv(env(b), async () => { expect(hookLauncherProblem('claude-code')).toBeNull(); });});- test('codex: post-upgrade rewrites them with matching trust, and a later setup keeps everything', async () => {+ test('codex: post-upgrade names the setup rerun and writes nothing; setup rewrites them with matching trust', async () => {const b = box();expect((await setup(b, ['codex', '--json'])).exitCode).toBe(0);downgradeCodex(b);expect(viaLauncher(b, codexSetupCommands(b))).toBe(false);+ const before = { hooks: readFileSync(hooksJson(b), 'utf8'), config: readFileSync(codexToml(b), 'utf8') };await withEnv(env(b), async () => {expect(hookLauncherProblem('codex')).toMatchObject({ lane: 'setup', reason: 'session_cwd' });- await refreshHookLaunchers(() => {});+ const lines: string[] = [];+ await refreshHookLaunchers((l) => lines.push(l));+ expect(lines.join('\n')).toContain("gbrain setup's codex hooks");+ expect(lines.join('\n')).toContain('run gbrain setup codex to rewrite them');+ expect(hookLauncherProblem('codex')).toMatchObject({ lane: 'setup', reason: 'session_cwd' });+ });+ expect({ hooks: readFileSync(hooksJson(b), 'utf8'), config: readFileSync(codexToml(b), 'utf8') }).toEqual(before);+ expect((await setup(b, ['codex', '--json'])).exitCode).toBe(0);+ expect(viaLauncher(b, codexSetupCommands(b))).toBe(true);+ await withEnv(env(b), async () => {expect(hookLauncherProblem('codex')).toBeNull();expect(inspectTurnHook('codex')).toMatchObject({ state: 'wired', via: 'setup' });});- expect(viaLauncher(b, codexSetupCommands(b))).toBe(true);expect((await setup(b, ['codex', '--json'])).doc.steps.map((s: any) => s.action)).toEqual(['keep', 'keep', 'keep', 'keep']);});- test('codex: post-upgrade leaves setup groups Codex does not run as is, so it grants no trust', async () => {+ test('codex: post-upgrade grants no trust to setup groups Codex does not run', async () => {const b = box();expect((await setup(b, ['codex', '--json'])).exitCode).toBe(0);downgradeCodex(b);@@ -1026,7 +1035,6 @@ describe('hooks written before the hook launcher (#8424): the next setup and posawait withEnv(env(b), async () => {const lines: string[] = [];await refreshHookLaunchers((l) => lines.push(l));- expect(lines.join('\n')).toContain("Codex does not run gbrain setup's codex SessionStart, UserPromptSubmit hook");expect(lines.join('\n')).not.toContain('now start gbrain from its own directory');expect(hookLauncherProblem('codex')).toMatchObject({ lane: 'setup', reason: 'session_cwd' });});