Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions src/genie-commands/doctor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { dirname, join } from 'node:path';
import { computeDirDigest, computeFileDigest } from '../lib/agent-sync.js';
import { reconcileCodexProjectMcp, resolveGitProjectRoots } from '../lib/codex-project-mcp.js';
import { CANONICAL_GENIE_SKILL_NAMES } from '../lib/runtime-integrations.js';
import { VERSION } from '../lib/version.js';
import {
MINIMUM_BUN_VERSION,
checkAgentSync,
Expand Down Expand Up @@ -219,6 +220,53 @@ describe('Codex doctor lifecycle results', () => {
}
});

test('post-A manifest truth: declaring NO mcpServers is the healthy shape; declaring one warns (live-QA regression)', async () => {
const root = mkdtempSync(join(tmpdir(), 'doctor-manifest-truth-'));
const priorCodexHome = process.env.CODEX_HOME;
process.env.CODEX_HOME = join(root, 'codex-home');
try {
trustProjectInCodexConfig(root);
const activePluginRoot = join(root, 'active-plugin');
mkdirSync(join(activePluginRoot, '.codex-plugin'), { recursive: true });
const manifestPath = join(activePluginRoot, '.codex-plugin', 'plugin.json');
const probe = {
cliAvailable: true,
status: 'ok' as const,
installed: true,
enabled: true,
// The probe still reports the stale pre-A manifest expectation; doctor
// must not surface it as a defect on a post-A generation.
usable: false,
usabilityDetail: 'plugin manifest does not point mcpServers to ./.mcp.json',
version: VERSION,
activePluginRoot,
detail: 'installed',
};

// Post-A shape: no mcpServers key → capability pass, plugin check pass.
writeFileSync(manifestPath, JSON.stringify({ name: 'genie', version: VERSION, skills: './skills/' }));
const healthy = await checkCodexIntegration(root, probe);
const capability = healthy.find((check) => check.name === 'Codex Genie MCP capability');
const plugin = healthy.find((check) => check.name === 'Codex Genie plugin');
expect(capability).toMatchObject({ status: 'pass' });
expect(capability?.detail).toContain('declares no MCP route');
expect(plugin).toMatchObject({ status: 'pass' });
expect(plugin?.detail).not.toContain('does not point mcpServers');
expect(plugin?.detail).not.toContain('unusable');

// Regression shape: a declared route is the defect (second Genie route).
writeFileSync(manifestPath, JSON.stringify({ name: 'genie', version: VERSION, mcpServers: './.mcp.json' }));
const regressed = await checkCodexIntegration(root, probe);
const declared = regressed.find((check) => check.name === 'Codex Genie MCP capability');
expect(declared).toMatchObject({ status: 'warn' });
expect(declared?.detail).toContain('still declares mcpServers');
} finally {
if (priorCodexHome === undefined) Reflect.deleteProperty(process.env, 'CODEX_HOME');
else process.env.CODEX_HOME = priorCodexHome;
rmSync(root, { recursive: true, force: true });
}
});

test('healthy source bundle cannot make an unproven active plugin capability pass', async () => {
const root = mkdtempSync(join(tmpdir(), 'doctor-active-plugin-'));
const priorCodexHome = process.env.CODEX_HOME;
Expand Down
66 changes: 43 additions & 23 deletions src/genie-commands/doctor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,14 +412,21 @@ function codexPluginCheck(state: CodexPluginProbe): CheckResult {
};
}
const current = state.version === VERSION;
const healthy = current && state.enabled === true && state.usable === true;
// Post-Group-A the plugin ships NO MCP declaration — the marker-owned project
// route is the only Codex route — so plugin health is installed+enabled+current.
// The probe still reports the OLD manifest expectation ("does not point
// mcpServers to ./.mcp.json"): on a post-A generation that IS the healthy
// shape, so it is filtered from diagnostics; every other usability detail
// (missing node/launcher/binary) stays visible as diagnostics.
const healthy = current && state.enabled === true;
const staleManifestComplaint = state.usabilityDetail?.includes('does not point mcpServers') === true;
const diagnostics =
state.usable === true || staleManifestComplaint ? '' : `; diagnostics: ${state.usabilityDetail ?? 'unknown'}`;
return {
name: 'Codex Genie plugin',
status: healthy ? 'pass' : 'warn',
detail: `v${state.version ?? 'unknown'}; ${state.enabled === true ? 'enabled' : 'disabled or unknown'}; ${state.usable === true ? 'MCP launcher usable' : `MCP launcher unusable (${state.usabilityDetail ?? 'unknown reason'})`} (CLI v${VERSION})`,
suggestion: healthy
? undefined
: 'Run `genie setup --codex` to refresh it; keep the absolute project fallback until launcher health passes.',
detail: `v${state.version ?? 'unknown'}; ${state.enabled === true ? 'enabled' : 'disabled or unknown'}; MCP route: marker-owned project route (plugin declares none)${diagnostics} (CLI v${VERSION})`,
suggestion: healthy ? undefined : 'Run `genie setup --codex` to activate the delivered generation.',
};
}

Expand Down Expand Up @@ -581,31 +588,44 @@ function codexPluginPayloadCheck(probe: CodexPluginProbe): CheckResult | null {
function codexPluginSurfaceChecks(probe: CodexPluginProbe): CheckResult[] {
if (!probe.installed) return [];
const manifest = probe.activePluginRoot ? join(probe.activePluginRoot, '.codex-plugin', 'plugin.json') : null;
let declared = false;
if (manifest !== null && existsSync(manifest)) {
try {
const parsed = JSON.parse(readFileSync(manifest, 'utf8')) as unknown;
declared =
typeof parsed === 'object' &&
parsed !== null &&
!Array.isArray(parsed) &&
(parsed as Record<string, unknown>).mcpServers === './.mcp.json';
} catch {
declared = false;
// Post-Group-A contract (Decisions 1/7): the codex plugin manifest MUST NOT
// declare mcpServers — a declaration would re-create the second (cache-root)
// Genie route the wish removed. Absence is the healthy shape.
let manifestState: 'unproven' | 'unreadable' | 'declares-none' | 'declares-route' = 'unproven';
if (manifest !== null) {
manifestState = 'unreadable';
if (existsSync(manifest)) {
try {
const parsed = JSON.parse(readFileSync(manifest, 'utf8')) as unknown;
if (typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)) {
manifestState =
(parsed as Record<string, unknown>).mcpServers === undefined ? 'declares-none' : 'declares-route';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Warn when the Codex manifest still advertises MCP

When an active post-A manifest omits mcpServers but still has interface.capabilities containing MCP, this branch classifies it as declares-none and the Codex Genie MCP capability check passes. The repo's post-A contract and release smoke checks reject both a mcpServers route and an advertised MCP capability, so genie doctor would miss a cached/installed plugin that still exposes the removed MCP surface in its metadata; include the capabilities field in this manifest-state check before returning a pass.

Useful? React with 👍 / 👎.

}
} catch {
manifestState = 'unreadable';
}
}
}
const payload = codexPluginPayloadCheck(probe);
return [
...(payload ? [payload] : []),
{
name: 'Codex Genie MCP capability',
status: declared ? 'pass' : 'warn',
detail: declared
? `stdio server declared by active plugin at ${probe.activePluginRoot}`
: manifest === null
? 'active installed plugin root is unproven; source-bundle declarations do not establish runtime health'
: `active plugin manifest is missing, corrupt, or does not declare ./.mcp.json: ${manifest}`,
suggestion: declared ? undefined : 'Run `genie setup --codex` to refresh the active plugin cache.',
status: manifestState === 'declares-none' ? 'pass' : 'warn',
detail:
manifestState === 'declares-none'
? `plugin declares no MCP route (marker-owned project route is authoritative) at ${probe.activePluginRoot}`
: manifestState === 'declares-route'
? `active plugin manifest still declares mcpServers — a second Genie route risks cache-root routing: ${manifest}`
: manifestState === 'unreadable'
? `active plugin manifest is missing or corrupt: ${manifest}`
: 'active installed plugin root is unproven; source-bundle declarations do not establish runtime health',
suggestion:
manifestState === 'declares-none'
? undefined
: manifestState === 'declares-route'
? 'Run `genie update` then `genie setup --codex` to activate a generation without a plugin MCP route.'
: 'Run `genie setup --codex` to refresh the active plugin cache.',
},
{
name: 'Codex hook review',
Expand Down
Loading