From cc8e6c64658da31a3d03e774ba9b3307265876c6 Mon Sep 17 00:00:00 2001 From: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> Date: Tue, 17 Nov 2026 07:57:15 +0800 Subject: [PATCH] fix(dsh): require Core 2.4 for recovery-capable initialization Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> --- packages/dsh-loopx-plugin/README.md | 15 +++-- .../smoke/dsh-goalbar-runtime-smoke.mjs | 2 +- .../smoke/dsh-profile-smoke.mjs | 2 +- packages/dsh-loopx-plugin/src/cli.ts | 6 +- packages/dsh-loopx-plugin/tests/cli.spec.ts | 16 ++--- .../dsh-loopx-plugin/tests/driver.spec.ts | 2 +- .../tests/init-command.spec.ts | 64 ++++++++++--------- 7 files changed, 55 insertions(+), 52 deletions(-) diff --git a/packages/dsh-loopx-plugin/README.md b/packages/dsh-loopx-plugin/README.md index fa051dc690..e64542f110 100644 --- a/packages/dsh-loopx-plugin/README.md +++ b/packages/dsh-loopx-plugin/README.md @@ -61,15 +61,16 @@ copy under `$DSH_AGENTS_HOME/runtime/dsh-loopx-plugin` (default `~/.agents/runtime/dsh-loopx-plugin`) and never mutates the system Python environment. This works with externally managed Python distributions that enforce PEP 668; the plugin does not use `--break-system-packages`. -This version requires LoopX 1.2.4 or newer, the published release that -includes the Windows peer-file fix. Bootstrap, Driver and GoalBar use the same +The next plugin release requires LoopX 2.4.0 or newer for the original-Turn +`quota receipt` reader. Publish the matching Core release before distributing +the plugin; published LoopX 2.3.0 does not provide that command. +Bootstrap, Driver and GoalBar use the same version floor; an older global or managed CLI is upgraded or rejected before business commands run. An explicit outdated `LOOPX_BIN` must be upgraded by its owner. Older plugin releases retain their original CLI requirements. -The continuation driver follows LoopX's context delivery setting on CLI 2.3 -and later. When the guard returns a capture reference, the driver reads the -admission fields from that same capture. The driver requests raw admission -JSON from older supported CLIs. +The continuation driver follows LoopX's context delivery setting. +When the guard returns a capture reference, the driver reads the +admission fields from that same capture. Install the prebuilt release into the web profile: ```bash @@ -491,7 +492,7 @@ The repair command has no arguments. Extra input returns a usage error before an model work or CLI probe. A valid invocation queues a bounded start followup on the exact receiving Agent, then probes the current LoopX installation. When the CLI is missing or lacks the DSH-native skill contract, it runs exactly one -fixed-argv `pip install --upgrade --target 'loopx>=1.2.4'`, writes a +fixed-argv `pip install --upgrade --target 'loopx>=2.4.0'`, writes a small managed Python launcher beside that target, then uses that same interpreter and launcher to install and read back the skills. Driver and GoalBar resolve this same managed runtime, including after an explicit repair. diff --git a/packages/dsh-loopx-plugin/smoke/dsh-goalbar-runtime-smoke.mjs b/packages/dsh-loopx-plugin/smoke/dsh-goalbar-runtime-smoke.mjs index 914895a8d5..183d6ebf3a 100644 --- a/packages/dsh-loopx-plugin/smoke/dsh-goalbar-runtime-smoke.mjs +++ b/packages/dsh-loopx-plugin/smoke/dsh-goalbar-runtime-smoke.mjs @@ -1110,7 +1110,7 @@ set -eu printf '%s\n' "$*" >> "${cliLog}" case " $* " in *" --version "*) - printf '%s\n' 'loopx 1.2.4' + printf '%s\n' 'loopx 2.4.0' exit 0 ;; esac diff --git a/packages/dsh-loopx-plugin/smoke/dsh-profile-smoke.mjs b/packages/dsh-loopx-plugin/smoke/dsh-profile-smoke.mjs index 47273153f7..51c049a8f6 100755 --- a/packages/dsh-loopx-plugin/smoke/dsh-profile-smoke.mjs +++ b/packages/dsh-loopx-plugin/smoke/dsh-profile-smoke.mjs @@ -212,7 +212,7 @@ async function exerciseInstalled(installed) { throw new hostModule.LoopXCliError('aborted', 'cancelled', false) } if (args.at(-1) === '--version') { - return { exitCode: 0, stdout: 'loopx 1.2.4\n', stderr: '' } + return { exitCode: 0, stdout: 'loopx 2.4.0\n', stderr: '' } } if (args.includes('--install')) { return { diff --git a/packages/dsh-loopx-plugin/src/cli.ts b/packages/dsh-loopx-plugin/src/cli.ts index 506a36a9d9..7402226fca 100644 --- a/packages/dsh-loopx-plugin/src/cli.ts +++ b/packages/dsh-loopx-plugin/src/cli.ts @@ -1,9 +1,9 @@ import { spawn } from 'node:child_process' import { statSync } from 'node:fs' -// 1.2.4 includes the released Windows peer-file fix. Bootstrap and every -// runtime consumer must use the same floor, including an existing global CLI. -export const MINIMUM_LOOPX_VERSION = '1.2.4' +// 2.4.0 adds the original-Turn receipt reader used by selection recovery. +// Bootstrap and every runtime consumer share this floor, including global CLIs. +export const MINIMUM_LOOPX_VERSION = '2.4.0' export type LoopXCliErrorKind = | 'aborted' diff --git a/packages/dsh-loopx-plugin/tests/cli.spec.ts b/packages/dsh-loopx-plugin/tests/cli.spec.ts index d6442da47c..f8604191ba 100644 --- a/packages/dsh-loopx-plugin/tests/cli.spec.ts +++ b/packages/dsh-loopx-plugin/tests/cli.spec.ts @@ -98,14 +98,14 @@ describe('runJsonCommand', () => { probes += 1 controller.abort() if (outcome === 'rejected-probe') throw new Error('probe closed during cancellation') - return { exitCode: outcome === 'valid-version' ? 0 : 1, stdout: 'loopx 1.2.4\n', stderr: '' } + return { exitCode: outcome === 'valid-version' ? 0 : 1, stdout: 'loopx 2.4.0\n', stderr: '' } }, })).rejects.toMatchObject({ kind: 'aborted', retryable: false }) expect(probes).toBe(1) }, ) - it.each(['0.5.4', '1.2.3', '1.2.4rc1', '1.2.4.dev1', 'smoke', '1.2.4unknown'])( + it.each(['0.5.4', '1.2.3', '1.2.4', '2.4.0rc1', '2.4.0.dev1', '2.3.0', 'smoke', '2.4.0unknown'])( 'rejects unavailable or pre-fix CLI version %s', async version => { await expect(resolveLoopXCommand({ env: { LOOPX_BIN: 'configured-loopx' }, @@ -114,7 +114,7 @@ describe('runJsonCommand', () => { }, ) - it.each(['1.2.4', '1.2.4+local', '1.2.4.post1', '1.2.5rc1', '2.0.0.dev1'])( + it.each(['2.4.0', '2.4.0+local', '2.4.0.post1', '2.4.1rc1', '3.0.0.dev1'])( 'accepts CLI release %s at or after the fixed floor', async version => { const command = await resolveLoopXCommand({ env: { LOOPX_BIN: 'configured-loopx' }, @@ -128,7 +128,7 @@ describe('runJsonCommand', () => { const command = await resolveLoopXCommand({ env: { PYTHON_BIN: 'fixture-python', LOOPX_BIN: '' }, runner: async file => ({ - exitCode: 0, stdout: `loopx ${file === 'loopx' ? '1.2.3' : '1.2.4'}\n`, stderr: '', + exitCode: 0, stdout: `loopx ${file === 'loopx' ? '2.3.0' : '2.4.0'}\n`, stderr: '', }), }) expect(command.file).toBe('fixture-python') @@ -141,7 +141,7 @@ describe('runJsonCommand', () => { env: { LOOPX_BIN: '' }, runner: async (file, args) => { attempted.push(`${file} ${args.join(' ')}`) - if (file === 'python') return { exitCode: 0, stdout: 'loopx 1.2.4\n', stderr: '' } + if (file === 'python') return { exitCode: 0, stdout: 'loopx 2.4.0\n', stderr: '' } throw new LoopXCliError('missing', 'missing', false) }, }) @@ -159,7 +159,7 @@ describe('runJsonCommand', () => { runner: async (file, args) => { expect(file).toBe(configured) expect(args).toEqual(['--version']) - return { exitCode: 0, stdout: 'loopx 1.2.4\n', stderr: '' } + return { exitCode: 0, stdout: 'loopx 2.4.0\n', stderr: '' } }, }) @@ -174,7 +174,7 @@ describe('runJsonCommand', () => { if (file === 'loopx') return { exitCode: 127, stdout: '', stderr: '' } expect(file).toBe(python) expect(args).toEqual(['-m', 'loopx.cli', '--version']) - return { exitCode: 0, stdout: 'loopx 1.2.4\n', stderr: '' } + return { exitCode: 0, stdout: 'loopx 2.4.0\n', stderr: '' } }, }) @@ -189,7 +189,7 @@ describe('runJsonCommand', () => { runner: async (file, args) => { expect(file).toBe(python) expect(args).toEqual([launcher, '--version']) - return { exitCode: 0, stdout: 'loopx 1.2.4\n', stderr: '' } + return { exitCode: 0, stdout: 'loopx 2.4.0\n', stderr: '' } }, }) diff --git a/packages/dsh-loopx-plugin/tests/driver.spec.ts b/packages/dsh-loopx-plugin/tests/driver.spec.ts index 537e78776d..582973b57d 100644 --- a/packages/dsh-loopx-plugin/tests/driver.spec.ts +++ b/packages/dsh-loopx-plugin/tests/driver.spec.ts @@ -365,7 +365,7 @@ function runnerFixture(options: { runner: async (_file, args) => { calls.push([...args]) if (args.at(-1) === '--version') { - return { exitCode: 0, stdout: 'loopx 1.2.4\n', stderr: '' } + return { exitCode: 0, stdout: 'loopx 2.4.0\n', stderr: '' } } if (args.includes('resolve-agent-thread')) { const threadIdIndex = args.indexOf('--thread-id') diff --git a/packages/dsh-loopx-plugin/tests/init-command.spec.ts b/packages/dsh-loopx-plugin/tests/init-command.spec.ts index 6937e150f5..13b10da036 100644 --- a/packages/dsh-loopx-plugin/tests/init-command.spec.ts +++ b/packages/dsh-loopx-plugin/tests/init-command.spec.ts @@ -131,7 +131,7 @@ function successfulRunner(options: { if (args.at(-1) === '--version') { options.events?.push('probe') if (!cliAvailable) throw new LoopXCliError('missing', 'missing', false) - return { exitCode: 0, stdout: 'loopx 1.2.4\n', stderr: '' } + return { exitCode: 0, stdout: 'loopx 2.4.0\n', stderr: '' } } if (args.includes('--install')) { options.events?.push('install-skills') @@ -240,7 +240,7 @@ describe('/loopx-init implementation', () => { const runner: FileRunner = async (_file, args) => { calls.push([...args]) if (args.at(-1) === '--version') { - return { exitCode: 0, stdout: 'loopx 1.2.4\n', stderr: '' } + return { exitCode: 0, stdout: 'loopx 2.4.0\n', stderr: '' } } if (args.includes('workflow-skills')) { if (args.includes('--install')) { @@ -262,7 +262,7 @@ describe('/loopx-init implementation', () => { }) expect(result).toEqual({ - cliVersion: 'loopx 1.2.4', + cliVersion: 'loopx 2.4.0', cliInstalled: false, skillsInstalled: true, skillsChanged: false, @@ -278,7 +278,7 @@ describe('/loopx-init implementation', () => { const runner: FileRunner = async (_file, args) => { calls.push([...args]) if (args.at(-1) === '--version') { - return { exitCode: 0, stdout: 'loopx 1.2.4\n', stderr: '' } + return { exitCode: 0, stdout: 'loopx 2.4.0\n', stderr: '' } } const operation = args.includes('--install') ? 'install' : 'inspect' return { @@ -316,7 +316,7 @@ describe('/loopx-init implementation', () => { } if (args.at(-1) === '--version') { if (!installed) throw new LoopXCliError('missing', 'missing', false) - return { exitCode: 0, stdout: 'loopx 1.2.4\n', stderr: '' } + return { exitCode: 0, stdout: 'loopx 2.4.0\n', stderr: '' } } if (args.includes('workflow-skills')) { const operation = args.includes('--install') ? 'install' : 'inspect' @@ -364,7 +364,7 @@ describe('/loopx-init implementation', () => { if (file !== 'python3.13' || !installed) { throw new LoopXCliError('missing', 'missing', false) } - return { exitCode: 0, stdout: 'loopx 1.2.4\n', stderr: '' } + return { exitCode: 0, stdout: 'loopx 2.4.0\n', stderr: '' } } if (args.includes('workflow-skills')) { const operation = args.includes('--install') ? 'install' : 'inspect' @@ -399,7 +399,7 @@ describe('/loopx-init implementation', () => { ))).toBe(true) const pipCall = calls.find(call => call.args.slice(0, 3).join(' ') === '-m pip install') expect(pipCall?.args).toContain('--target') - expect(pipCall?.args.at(-1)).toBe('loopx>=1.2.4') + expect(pipCall?.args.at(-1)).toBe('loopx>=2.4.0') expect(pipCall?.args[pipCall.args.indexOf('--target') + 1]).toBe( '/fixture/runtime/site-packages', ) @@ -437,7 +437,7 @@ describe('/loopx-init implementation', () => { } if (args.at(-1) === '--version') { if (!installed) throw new LoopXCliError('missing', 'missing', false) - return { exitCode: 0, stdout: 'loopx 1.2.4\n', stderr: '' } + return { exitCode: 0, stdout: 'loopx 2.4.0\n', stderr: '' } } if (args.includes('workflow-skills')) { const operation = args.includes('--install') ? 'install' : 'inspect' @@ -509,7 +509,7 @@ describe('/loopx-init implementation', () => { if (file !== 'python3.14' || !installed) { throw new LoopXCliError('missing', 'missing', false) } - return { exitCode: 0, stdout: 'loopx 1.2.4\n', stderr: '' } + return { exitCode: 0, stdout: 'loopx 2.4.0\n', stderr: '' } } if (args.includes('workflow-skills')) { const operation = args.includes('--install') ? 'install' : 'inspect' @@ -587,7 +587,7 @@ describe('/loopx-init implementation', () => { calls.push({ file, args: [...args] }) if (args.at(-1) === '--version') { if (args[0] !== launcherPath) throw new LoopXCliError('missing', 'missing', false) - return { exitCode: 0, stdout: 'loopx 1.2.4\n', stderr: '' } + return { exitCode: 0, stdout: 'loopx 2.4.0\n', stderr: '' } } if (args.includes('workflow-skills')) { const operation = args.includes('--install') ? 'install' : 'inspect' @@ -621,7 +621,7 @@ describe('/loopx-init implementation', () => { } }) - it('upgrades a pre-1.2.4 CLI before inspecting or mutating skills', async () => { + it('upgrades a pre-2.4.0 CLI before inspecting or mutating skills', async () => { let upgraded = false let pipCalls = 0 let prematureWorkflowCalls = 0 @@ -633,7 +633,7 @@ describe('/loopx-init implementation', () => { return { exitCode: 0, stdout: 'pip fixture', stderr: '' } } if (args.at(-1) === '--version') { - return { exitCode: 0, stdout: `loopx ${upgraded ? '1.2.4' : '1.2.3'}\n`, stderr: '' } + return { exitCode: 0, stdout: `loopx ${upgraded ? '2.4.0' : '2.3.0'}\n`, stderr: '' } } if (args.slice(0, 3).join(' ') === '-m pip install') { pipCalls += 1 @@ -665,18 +665,20 @@ describe('/loopx-init implementation', () => { expect(prematureWorkflowCalls).toBe(0) }) - it('fails an explicit old CLI before pip installation or skill mutation', async () => { - const calls: string[][] = [] - await expect(initializeLoopX({ - env: { LOOPX_BIN: 'explicit-old-loopx' }, - runner: async (file, args) => { - expect(file).toBe('explicit-old-loopx') - calls.push([...args]) - return { exitCode: 0, stdout: 'loopx 1.2.3\n', stderr: '' } - }, - })).rejects.toMatchObject({ stage: 'probe', causeKind: 'incompatible' }) - expect(calls).toEqual([['--version']]) - }) + it.each(['1.2.3', '1.2.4', '2.3.0', '2.4.0rc1'])( + 'fails explicit unsupported CLI %s before pip installation or skill mutation', async version => { + const calls: string[][] = [] + await expect(initializeLoopX({ + env: { LOOPX_BIN: 'explicit-old-loopx' }, + runner: async (file, args) => { + expect(file).toBe('explicit-old-loopx') + calls.push([...args]) + return { exitCode: 0, stdout: `loopx ${version}\n`, stderr: '' } + }, + })).rejects.toMatchObject({ stage: 'probe', causeKind: 'incompatible' }) + expect(calls).toEqual([['--version']]) + }, + ) it.each([ ['created packaged skill', 'created', 'unchanged'], @@ -722,7 +724,7 @@ describe('/loopx-init implementation', () => { ) => { const runner: FileRunner = async (_file, args) => { if (args.at(-1) === '--version') { - return { exitCode: 0, stdout: 'loopx 1.2.4\n', stderr: '' } + return { exitCode: 0, stdout: 'loopx 2.4.0\n', stderr: '' } } if (args.includes('--install')) { return { @@ -742,7 +744,7 @@ describe('/loopx-init implementation', () => { let installCalls = 0 const runner: FileRunner = async (_file, args) => { if (args.at(-1) === '--version') { - return { exitCode: 0, stdout: 'loopx 1.2.4\n', stderr: '' } + return { exitCode: 0, stdout: 'loopx 2.4.0\n', stderr: '' } } if (args.includes('--install')) { installCalls += 1 @@ -773,7 +775,7 @@ describe('/loopx-init implementation', () => { let inspectCalls = 0 const runner: FileRunner = async (_file, args) => { if (args.at(-1) === '--version') { - return { exitCode: 0, stdout: 'loopx 1.2.4\n', stderr: '' } + return { exitCode: 0, stdout: 'loopx 2.4.0\n', stderr: '' } } if (args.includes('--install')) { return { exitCode: 0, stdout: workflowPayload('install'), stderr: '' } @@ -806,7 +808,7 @@ describe('/loopx-init implementation', () => { let installCalls = 0 const runner: FileRunner = async (_file, args) => { if (args.at(-1) === '--version') { - return { exitCode: 0, stdout: 'loopx 1.2.4\n', stderr: '' } + return { exitCode: 0, stdout: 'loopx 2.4.0\n', stderr: '' } } if (args.includes('--install')) { installCalls += 1 @@ -932,7 +934,7 @@ describe('/loopx-init followups', () => { let installCalls = 0 const runner: FileRunner = async (_file, args) => { if (args.at(-1) === '--version') { - return { exitCode: 0, stdout: 'loopx 1.2.4\n', stderr: '' } + return { exitCode: 0, stdout: 'loopx 2.4.0\n', stderr: '' } } if (args.includes('--install')) { installCalls += 1 @@ -970,7 +972,7 @@ describe('/loopx-init followups', () => { let installCalls = 0 const runner: FileRunner = async (_file, args) => { if (args.at(-1) === '--version') { - return { exitCode: 0, stdout: 'loopx 1.2.4\n', stderr: '' } + return { exitCode: 0, stdout: 'loopx 2.4.0\n', stderr: '' } } if (args.includes('--install')) { installCalls += 1 @@ -1013,7 +1015,7 @@ describe('/loopx-init followups', () => { expect(result).toEqual({ kind: 'success', text: [ - 'LoopX ready (loopx 1.2.4).', + 'LoopX ready (loopx 2.4.0).', 'CLI already compatible.', 'DSH LoopX skills installed or updated and verified.', 'No DSH restart is required; use the `loopx` skill with your task.',