MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / main

Function main

graph-ui/tools/verify-models.mjs:181–300  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

179}
180
181async function main() {
182 const started = Date.now();
183 let port = 0;
184 const report = {
185 files: 0,
186 checksumsOk: false,
187 llamaServerRuns: false,
188 version: '',
189 };
190 const extras = { models: [], missing: [], unexpected: [], errors: [] };
191
192 if (!existsSync(SUMS)) {
193 throw new Error(`models/SHA256SUMS fehlt: ${SUMS}`);
194 }
195 if (!existsSync(HERKUNFT)) {
196 throw new Error(`vendor/llama/HERKUNFT.md fehlt: ${HERKUNFT}`);
197 }
198
199 // ------------------------------------------------------ 1. Pruefsummen
200 const entries = parseSums(await readFile(SUMS, 'utf8'));
201 report.files = entries.length;
202 let allOk = entries.length > 0;
203 for (const entry of entries) {
204 const path = join(MODELS_DIR, entry.file);
205 const record = { file: entry.file, expected: entry.expected, exists: existsSync(path), size: 0, actual: '', ok: false };
206 if (entry.malformed) {
207 record.note = 'Zeile hat nicht die Form "<sha256> <datei>"';
208 extras.errors.push(`unlesbare Zeile in SHA256SUMS: ${entry.file}`);
209 allOk = false;
210 extras.models.push(record);
211 continue;
212 }
213 if (!record.exists) {
214 extras.missing.push(entry.file);
215 allOk = false;
216 extras.models.push(record);
217 continue;
218 }
219 record.size = statSync(path).size;
220 record.actual = await sha256(path);
221 record.ok = record.actual === entry.expected;
222 if (!record.ok) {
223 allOk = false;
224 }
225 log(`${record.ok ? 'ok ' : 'FALSCH'} ${entry.file} (${record.size} Byte)`);
226 extras.models.push(record);
227 }
228 report.checksumsOk = allOk;
229
230 // Was in models/ liegt, aber in keiner Zeile steht. Kein Fehler, aber ein
231 // Befund: eine Datei ohne Pruefsumme ist eine Datei ohne Herkunft.
232 const { readdir } = await import('node:fs/promises');
233 const named = new Set(entries.map((entry) => entry.file));
234 for (const name of await readdir(MODELS_DIR)) {
235 if (name !== 'SHA256SUMS' && !named.has(name)) {
236 extras.unexpected.push(name);
237 }
238 }

Callers 1

verify-models.mjsFile · 0.70

Calls 11

findFreePortFunction · 0.90
sleepFunction · 0.90
countListenersFunction · 0.90
parseSumsFunction · 0.85
readdirFunction · 0.85
serverVersionFunction · 0.85
smallestModelFunction · 0.85
loadSmokeFunction · 0.85
sha256Function · 0.70
logFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected