* fix(#1521): resolve own runtime + worktrees-off for all non-Claude installs Generalizes the Codex-only #1515/#1519 fix to every non-Claude runtime, and wires it into the real install path (where it was previously dead-on-arrival). Root causes: 1. The runtime-default stamping lived only in `_applyRuntimeRewrites`, but the installer emits `gsd-core/workflows/*.md` via `copyWithPathReplacement`, which never calls it — so a real `--codex`/`--cursor`/etc. install emitted `--default claude` and worktrees-on. RUNTIME mis-resolved to claude and the workflow ran executors unisolated against the main checkout. (#1515/#1519 were also dead-on-arrival in real installs; this repairs them.) 2. Only `case 'codex'` was stamped; every other non-Claude runtime kept the Claude default. Fix: - New `_stampNonClaudeRuntimeDefaults(content, runtime)` (single shared helper) stamps `--default <runtime>` + `use_worktrees=false` for every `runtime != claude`; called from both `_applyRuntimeRewrites` and, crucially, `copyWithPathReplacement` in bin/install.js (the real workflow emit path). - Generalize the fail-closed worktree guard `= codex` -> `!= claude` in execute-phase/quick/diagnose-issues (worktree isolation is Claude-Code-only). - Flip manager/autonomous inline-vs-background gating to `codex -> background, everything-else -> inline` (research: only Codex can background-nest the pipeline's subagents; all others run inline, which they support). Worktree-capability determination is research-backed (official docs for all 14 non-Claude runtimes: none honor GSD's isolation="worktree" mechanism, only Codex background-nests). New end-to-end real-install test asserts the EMITTED workflow is stamped — the regression guard that would have caught the dead-on-arrival bug. Closes #1521 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013vX5eUtWa2wsZEyeMf5i3r * chore(#1521): backfill changeset PR number (#1537) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013vX5eUtWa2wsZEyeMf5i3r --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
71 lines
2.8 KiB
JavaScript
71 lines
2.8 KiB
JavaScript
/**
|
|
* Regression test for bug #3360.
|
|
*
|
|
* Codex does not have a direct equivalent of Claude Code's
|
|
* `Agent(... isolation="worktree")`. The execute-phase workflow must fail
|
|
* closed for Codex + workflow.use_worktrees=true instead of spawning
|
|
* workspace-write executors in the main checkout.
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
process.env.GSD_TEST_MODE = '1';
|
|
|
|
const { describe, test } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
|
|
const ROOT = path.join(__dirname, '..');
|
|
const EXECUTE_PHASE = path.join(ROOT, 'gsd-core', 'workflows', 'execute-phase.md');
|
|
const { getCodexSkillAdapterHeader } = require('../bin/install.js');
|
|
|
|
function parseWorkflowSteps(content) {
|
|
return [...content.matchAll(/<step name="([^"]+)"[^>]*>([\s\S]*?)<\/step>/g)]
|
|
.map((match) => {
|
|
const body = match[2];
|
|
return {
|
|
name: match[1],
|
|
// After #3797 architectural fix, callsites use gsd_run
|
|
readsRuntimeConfig: body.includes('RUNTIME=$(gsd_run query config-get runtime --default claude'),
|
|
// #1521: guard generalized from Codex-specific to all non-Claude runtimes
|
|
codexWorktreeGuard: body.includes('git worktree isolation') && body.includes('unsupported on runtime'),
|
|
worktreeDispatchGuidance: body.includes('isolation="worktree"'),
|
|
};
|
|
});
|
|
}
|
|
|
|
function executePhaseWorktreeContract(content) {
|
|
const steps = parseWorkflowSteps(content);
|
|
const initializeIndex = steps.findIndex((step) => step.name === 'initialize');
|
|
const firstWorktreeDispatchIndex = steps.findIndex((step) => step.worktreeDispatchGuidance);
|
|
assert.notEqual(initializeIndex, -1, 'workflow must have an initialize step');
|
|
assert.notEqual(firstWorktreeDispatchIndex, -1, 'workflow must still document worktree dispatch guidance');
|
|
|
|
const initialize = steps[initializeIndex];
|
|
return {
|
|
initializeReadsRuntimeConfig: initialize.readsRuntimeConfig,
|
|
initializeHasCodexWorktreeGuard: initialize.codexWorktreeGuard,
|
|
guardStepPrecedesWorktreeDispatch: initializeIndex <= firstWorktreeDispatchIndex,
|
|
};
|
|
}
|
|
|
|
describe('#3360 — Codex execute-phase fails closed for unsupported worktree isolation', () => {
|
|
test('execute-phase reads runtime before worktree dispatch and blocks Codex worktree mode', () => {
|
|
const workflow = fs.readFileSync(EXECUTE_PHASE, 'utf8');
|
|
const contract = executePhaseWorktreeContract(workflow);
|
|
|
|
assert.deepEqual(contract, {
|
|
initializeReadsRuntimeConfig: true,
|
|
initializeHasCodexWorktreeGuard: true,
|
|
guardStepPrecedesWorktreeDispatch: true,
|
|
});
|
|
});
|
|
|
|
test('Codex adapter documents that worktree isolation has no direct spawn_agent mapping', () => {
|
|
const header = getCodexSkillAdapterHeader('gsd-execute-phase');
|
|
assert.match(header, /isolation="worktree"/);
|
|
assert.match(header, /no direct Codex mapping/i);
|
|
});
|
|
});
|