fix: resolve NemoClaw registries across gateway ports (#48)

This commit is contained in:
mmckeen-nv
2026-09-12 23:09:27 -07:00
committed by GitHub
parent 6154088197
commit 85c6777c55
5 changed files with 142 additions and 27 deletions
+60
View File
@@ -0,0 +1,60 @@
import assert from 'node:assert/strict'
import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises'
import os from 'node:os'
import path from 'node:path'
import {
discoverNemoClawRegistryFiles,
findNemoClawRegistryEntry,
listNemoClawRegistryCandidates,
} from '../app/lib/nemoclawRegistry.mjs'
const home = await mkdtemp(path.join(os.tmpdir(), 'nemoclaw-registry-roots-'))
try {
const root = path.join(home, '.nemoclaw')
await mkdir(path.join(root, 'gateways', '8990'), { recursive: true })
await mkdir(path.join(root, 'gateways', 'not-a-port'), { recursive: true })
await writeFile(path.join(root, 'sandboxes.json'), JSON.stringify({
defaultSandbox: 'base-box',
sandboxes: {
'base-box': { name: 'base-box', imageTag: 'base:image', createdAt: '2026-09-01' },
},
}))
await writeFile(path.join(root, 'gateways', '8990', 'sandboxes.json'), JSON.stringify({
defaultSandbox: 'port-box',
sandboxes: {
'port-box': { name: 'port-box', imageTag: 'port:image', createdAt: '2026-09-02' },
},
}))
await writeFile(path.join(root, 'gateways', 'not-a-port', 'sandboxes.json'), '{}')
const files = discoverNemoClawRegistryFiles(home)
assert.deepEqual(files, [
path.join(root, 'sandboxes.json'),
path.join(root, 'gateways', '8990', 'sandboxes.json'),
], 'registry discovery must include the default root and numeric alternate-port roots only')
assert.equal(
findNemoClawRegistryEntry('port-box', home)?.entry.imageTag,
'port:image',
'quick deploy must resolve image metadata from an alternate-port registry',
)
assert.deepEqual(
listNemoClawRegistryCandidates(home),
['base-box', 'port-box'],
'defaults remain first and registered candidates are deduplicated across roots',
)
await writeFile(path.join(root, 'sandboxes.json'), JSON.stringify({
sandboxes: { duplicate: { name: 'port-box', imageTag: 'wrong:image' } },
}))
assert.throws(
() => findNemoClawRegistryEntry('port-box', home),
/multiple NemoClaw gateway registries/,
'ambiguous cross-port registrations must fail closed',
)
console.log('nemoclaw-registry-roots-check: PASS cross-port registry resolution assertions')
} finally {
await rm(home, { recursive: true, force: true })
}
+1 -1
View File
@@ -102,7 +102,7 @@ assert.match(createRouteSource, /label: "Fresh Hermes Sandbox"/, 'Hermes sandbox
assert.match(createRouteSource, /source: "~\/NemoClaw\/agents\/hermes\/Dockerfile"/, 'Hermes sandbox creation must point at the upstream Hermes agent source')
assert.match(createRouteSource, /id: "nemoclaw-deepagents-code"/, 'create API must expose Deep Agents Code sandbox creation')
assert.match(createRouteSource, /source: "~\/NemoClaw\/agents\/langchain-deepagents-code\/manifest\.yaml"/, 'Deep Agents Code sandbox creation must point at the upstream agent manifest')
assert.match(createRouteSource, /readNemoClawRegistry/, 'image redeploy must discover the default NemoClaw sandbox image automatically')
assert.match(createRouteSource, /findNemoClawRegistryEntry/, 'image redeploy must discover NemoClaw sandbox images across default and alternate-port registries')
assert.match(createRouteSource, /listOpenShellSandboxNames/, 'image redeploy must fall back to live OpenShell inventory when registry entries are stale')
assert.match(createRouteSource, /resolveSourcePodImage\(sourceSandboxName, sandboxName\)/, 'image redeploy must allow optional explicit source while defaulting automatically')
assert.match(createRouteSource, /"--from",\s*sourceImage/, 'image redeploy must pass the resolved image to openshell sandbox create')