From 8f003953829d4f628f660dc4638da8e8fb74e2ef Mon Sep 17 00:00:00 2001 From: garrytan Date: Thu, 1 Oct 2026 00:38:34 +0000 Subject: [PATCH] test(design-review plugin handoff): quoted report text is not an install command PR lane 36794871032: every behavioral check passed except noInstallOrOverride, which matched "no `npx impeccable`" inside the quoted heredoc that wrote detector-output.md. Nothing was installed or downloaded. The check now drops quoted-delimiter heredoc bodies (literal data) before matching; unquoted bodies, which can expand $(...), and unterminated bodies stay checked. Free controls cover the captured write, bare npx, an IMPECCABLE_BIN override, an unquoted $(npx ...), npx after the delimiter and an unterminated body. --- test/skill-e2e-design.test.ts | 36 ++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/test/skill-e2e-design.test.ts b/test/skill-e2e-design.test.ts index 808a2a595..e31052cf5 100644 --- a/test/skill-e2e-design.test.ts +++ b/test/skill-e2e-design.test.ts @@ -776,6 +776,40 @@ function detectorReportEntries(report: string): string[] { return report.split(/(?=^[\t ]*(?:#{1,6}\s+|[-*|]\s*|\d+[.)]\s+)?(?:\*\*|`)?FINDING-\d+)/m); } +const INSTALL_OR_OVERRIDE = /\bnpx\b|gstack-design-detect\.ts install|\b(?:curl|wget|npm install|bun add)\b|IMPECCABLE_BIN\s*=/; + +/** A quoted-delimiter heredoc body is literal data, so a report that says + * "no npx" is not an npx run. Unquoted bodies still expand and stay checked; + * an unterminated body keeps the whole command checked. */ +function commandRunsInstallOrOverride(command: string): boolean { + const kept: string[] = []; + let delimiter: string | undefined, tabs = false; + for (const line of command.split('\n')) { + if (delimiter !== undefined) { + if ((tabs ? line.replace(/^\t*/, '') : line) === delimiter) delimiter = undefined; + continue; + } + kept.push(line); + const quoted = /<<(-)?[ \t]*(?:'([^'\n]+)'|"([^"\n]+)"|\\(\w+))/.exec(line); + if (quoted) { delimiter = quoted[2] ?? quoted[3] ?? quoted[4]; tabs = !!quoted[1]; } + } + return INSTALL_OR_OVERRIDE.test(delimiter === undefined ? kept.join('\n') : command); +} + +if (!evalsEnabled) test('plugin handoff counts executed install commands, not quoted report text', () => { + // PR lane 36794871032: the report heredoc said "no `npx impeccable`" and failed noInstallOrOverride. + const reportWrite = "cat > detector-output.md <<'EOF'\n# Detector output\n- No install, no launcher, no `npx impeccable`, no Impeccable skill files read.\nEOF\necho \"written: $(wc -l < detector-output.md) lines\"; git status --short"; + expect(commandRunsInstallOrOverride(reportWrite)).toBe(false); + expect(commandRunsInstallOrOverride(reportWrite.replace("<<'EOF'", '<<"EOF"'))).toBe(false); + expect(commandRunsInstallOrOverride(reportWrite.replace("<<'EOF'", '<<\\EOF'))).toBe(false); + expect(commandRunsInstallOrOverride(reportWrite.replace("<<'EOF'", "<<-'EOF'").replace('\nEOF\n', '\n\t\tEOF\n'))).toBe(false); + expect(commandRunsInstallOrOverride('npx impeccable detect .')).toBe(true); + expect(commandRunsInstallOrOverride('IMPECCABLE_BIN=/tmp/x bun run detect.ts probe')).toBe(true); + expect(commandRunsInstallOrOverride(reportWrite.replace("<<'EOF'", '< { const report = `### FINDING-001 \`[low-contrast]\` — impact=high — DEFERRED handoff=\`/impeccable colorize\` @@ -933,7 +967,7 @@ Write the probe's first line and skill-presence line, then one FINDING-NNN entry probeReported: report.includes(`IMPECCABLE_READY: ${fixture.engines['4.10.0']}`) && report.includes('IMPECCABLE_SKILL: present'), probeExecuted: commands.some(command => /gstack-design-detect\.ts probe/.test(command)), scanExecuted: commands.some(command => /gstack-design-detect\.ts scan --changed main/.test(command)), - noInstallOrOverride: !commands.some(command => /\bnpx\b|gstack-design-detect\.ts install|\b(?:curl|wget|npm install|bun add)\b|IMPECCABLE_BIN\s*=/.test(command)), + noInstallOrOverride: !commands.some(commandRunsInstallOrOverride), oneNewEngineInvocation: invocations.length === 1, oldEngineNotExecuted: !fs.existsSync(path.join(fixture.dir, '4.3.1.jsonl')), launcherNotExecuted: !fs.existsSync(path.join(fixture.dir, 'launcher-ran')),