fix: keep local home paths and addresses out of the test fixtures

Three test-only spots had baked in the machine this repository was developed
on, and the repository is publicly readable, so they shipped that machine's
shape to anyone who cloned it:

  * the end-to-end embedding backend was pinned to a private LAN address;
    it is now read from DSH_SLOPO_E2E_API_BASE, defaulting to Ollama's own
    loopback address, so the machine running the suite supplies its own;
  * the real-slopo test resolved discovery from a hardcoded root home, which
    meant it could only ever run for one user — it resolves from the running
    user's home now, which is also the fix for everyone else;
  * the harness-slot contract tests read the global npm tree by absolute
    path; they go through this repository's own node_modules symlink, which
    is already relative to the checkout.

No user-facing behaviour changes: the test files are not in the published
package, and the default configuration was already free of machine-specific
values — every address, path and key defaults to empty and is resolved per
user at runtime.
This commit is contained in:
dsh-slopo agent committed 2026-09-26 07:05:33 +01:00
1 parent 1b2ab3613f
commit 6beb4c0d39
3 files changed
+47 -27

No files matched your search

+9 -2
View File
@@ -31,11 +31,18 @@ import assert from 'node:assert/strict'
import { existsSync, readFileSync } from 'node:fs' import { existsSync, readFileSync } from 'node:fs'
import { join } from 'node:path' import { join } from 'node:path'
import { test } from 'node:test' import { test } from 'node:test'
import { fileURLToPath } from 'node:url'
const SOURCE = readFileSync(new URL('../client/client.js', import.meta.url), 'utf8') const SOURCE = readFileSync(new URL('../client/client.js', import.meta.url), 'utf8')
/** Where a global dsh installation keeps its packages, if there is one. */ /**
const DSH_PACKAGES = '/usr/local/lib/node_modules/@deepseek-ai/dsh/node_modules/@deepseek-ai' * The installed harness's packages, reached through this repository's own
* `node_modules/@deepseek-ai` symlink rather than a committed absolute path —
* the link is what makes the `@deepseek-ai/*` imports resolve during tests in
* the first place, so it is the one address that is already relative to the
* checkout.
*/
const DSH_PACKAGES = fileURLToPath(new URL('../node_modules/@deepseek-ai/', import.meta.url))
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// The two doubles // The two doubles
+5 -1
View File
@@ -477,7 +477,11 @@ test(
sourceDir: join(repo, 'src'), sourceDir: join(repo, 'src'),
embeddingModel: 'ollama/unclemusclez/jina-embeddings-v2-base-code:latest', embeddingModel: 'ollama/unclemusclez/jina-embeddings-v2-base-code:latest',
embeddingDimensions: 768, embeddingDimensions: 768,
embeddingApiBase: 'http://10.50.1.2:11434', // Where the real embedding backend lives is a property of the machine
// running the E2E suite, not of this repository, so it is read from the
// environment rather than committed. The default is Ollama's own
// loopback address.
embeddingApiBase: process.env.DSH_SLOPO_E2E_API_BASE ?? 'http://127.0.0.1:11434',
}) })
const tool = state.tools.get('slopo') const tool = state.tools.get('slopo')
+33 -24
View File
@@ -17,7 +17,7 @@ import {
slopoCandidates, slopoCandidates,
uvInstallArgs, uvInstallArgs,
} from '../lib/slopo.js' } from '../lib/slopo.js'
import { managedSlopoPath, resolveDshHome, workspaceKey, workspaceStateDir } from '../lib/paths.js' import { managedSlopoPath, resolveDshHome, userLocalSlopoPath, workspaceKey, workspaceStateDir } from '../lib/paths.js'
test('findSlopo prefers the managed install over PATH', () => { test('findSlopo prefers the managed install over PATH', () => {
const home = '/dsh' const home = '/dsh'
@@ -152,26 +152,35 @@ test('workspace state lives under the harness home, not next to the code', () =>
assert.match(workspaceStateDir('/dsh', '/repo'), /^\/dsh\/dsh-slopo\/workspaces\/repo-[0-9a-f]{8}$/) assert.match(workspaceStateDir('/dsh', '/repo'), /^\/dsh\/dsh-slopo\/workspaces\/repo-[0-9a-f]{8}$/)
}) })
test('the generated config is accepted by the real slopo', { skip: !existsSync(managedSlopoPath('/root/.dsh')) && !existsSync('/root/.local/bin/slopo') }, () => { test(
const binary = findSlopo('/root/.dsh') 'the generated config is accepted by the real slopo',
assert.ok(binary, 'expected a slopo binary for this test') {
const dir = mkdtempSync(join(tmpdir(), 'dsh-slopo-conf-')) // Discovery resolves from the RUNNING user's home, not from a committed
const configPath = join(dir, 'slopo.conf.yaml') // absolute one: a hardcoded home directory only ever matched one machine,
writeFileSync( // and it published that machine's layout to everyone else.
configPath, skip: !existsSync(managedSlopoPath(resolveDshHome())) && !existsSync(userLocalSlopoPath()),
renderSlopoConfig({ },
source_dir: dir, () => {
db_file: join(dir, 'slopo.db'), const binary = findSlopo(resolveDshHome())
ignore_file: join(dir, 'slopo.ignore.txt'), assert.ok(binary, 'expected a slopo binary for this test')
agent_log_file: join(dir, 'slopo.agent.log'), const dir = mkdtempSync(join(tmpdir(), 'dsh-slopo-conf-'))
embedding_model: 'ollama/example:latest', const configPath = join(dir, 'slopo.conf.yaml')
embedding_dimensions: 768, writeFileSync(
embedding_params: { api_base: 'http://127.0.0.1:11434' }, configPath,
source_dir_exclude: ['**/test/**'], renderSlopoConfig({
}), source_dir: dir,
) db_file: join(dir, 'slopo.db'),
const out = execFileSync(binary, ['--config', configPath, 'show-config'], { encoding: 'utf8' }) ignore_file: join(dir, 'slopo.ignore.txt'),
assert.match(out, /embedding_model: ollama\/example:latest/) agent_log_file: join(dir, 'slopo.agent.log'),
assert.match(out, /embedding_dimensions: 768/) embedding_model: 'ollama/example:latest',
assert.match(out, /api_base: http:\/\/127\.0\.0\.1:11434/) embedding_dimensions: 768,
}) embedding_params: { api_base: 'http://127.0.0.1:11434' },
source_dir_exclude: ['**/test/**'],
}),
)
const out = execFileSync(binary, ['--config', configPath, 'show-config'], { encoding: 'utf8' })
assert.match(out, /embedding_model: ollama\/example:latest/)
assert.match(out, /embedding_dimensions: 768/)
assert.match(out, /api_base: http:\/\/127\.0\.0\.1:11434/)
},
)