dsh-memu-memory 1.4.3 → 1.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +3 -1
- package/CHANGELOG.md +15 -0
- package/README.md +34 -15
- package/README.zh.md +35 -13
- package/assets/screenshots/drawer.jpg +0 -0
- package/assets/screenshots/libraries.jpg +0 -0
- package/assets/screenshots/mobile.jpg +0 -0
- package/assets/screenshots/relations.jpg +0 -0
- package/assets/screenshots/settings.jpg +0 -0
- package/assets/screenshots/webui-dark.jpg +0 -0
- package/assets/screenshots/webui-memory.jpg +0 -0
- package/docs/client-conventions.md +19 -3
- package/docs/contributing.md +4 -2
- package/docs/env-and-commands.md +9 -1
- package/docs/graph-scale.md +214 -0
- package/docs/lexicon-recall.md +100 -0
- package/docs/mcp-porting.md +8 -6
- package/docs/memory-semantics.md +35 -3
- package/docs/pending-work.md +3 -1
- package/docs/retention.md +83 -0
- package/docs/rt-index.md +452 -0
- package/docs/scale-performance.md +101 -0
- package/docs/token-budget.md +92 -0
- package/docs/troubleshooting.md +50 -11
- package/lib/auto-link/apply.js +7 -2
- package/lib/auto-link/candidates.js +32 -10
- package/lib/backup.js +67 -32
- package/lib/binding-diagnostics.js +1 -1
- package/lib/bounded-cache.js +80 -0
- package/lib/client.js +2096 -409
- package/lib/consolidation-ledger.js +21 -4
- package/lib/consolidation-worker.js +14 -1
- package/lib/cycle.js +16 -11
- package/lib/diagnostic-context.js +372 -0
- package/lib/diagnostics.js +147 -61
- package/lib/embedding-download.js +7 -8
- package/lib/engine-sources.js +286 -0
- package/lib/engine.js +23 -10
- package/lib/entity-repair.js +43 -13
- package/lib/entity-review.js +64 -0
- package/lib/environment-check.js +348 -36
- package/lib/feedback.js +25 -0
- package/lib/global-graph.js +46 -2
- package/lib/graph-adjacency-index.js +525 -0
- package/lib/graph-overview.js +293 -0
- package/lib/graph.js +658 -105
- package/lib/inbound.js +44 -15
- package/lib/index-pages.js +57 -0
- package/lib/index.js +44 -6
- package/lib/inject.js +119 -50
- package/lib/lexicon-rt-source.js +25 -0
- package/lib/lexicon-rt-worker.js +26 -0
- package/lib/lexicon-rt.js +224 -0
- package/lib/lexicon-scope.js +56 -5
- package/lib/lexicon.js +143 -54
- package/lib/local-vector-service.js +3 -0
- package/lib/maintenance-ledger.js +542 -12
- package/lib/managed-runtime.js +260 -80
- package/lib/media.js +1 -1
- package/lib/memory.js +564 -131
- package/lib/port-surface.js +96 -11
- package/lib/preset-mount.js +13 -7
- package/lib/private.js +47 -21
- package/lib/recall-cache.js +20 -34
- package/lib/retention.js +173 -0
- package/lib/rpc.js +135 -52
- package/lib/rt-index/builder.js +209 -0
- package/lib/rt-index/format.js +231 -0
- package/lib/rt-index/manifest.js +105 -0
- package/lib/rt-index/reader.js +673 -0
- package/lib/rt-index-retention.js +151 -0
- package/lib/rt-index-service.js +283 -0
- package/lib/rt-index-worker.js +21 -0
- package/lib/salient-wake.js +55 -4
- package/lib/state.js +195 -24
- package/lib/temporal.js +39 -13
- package/lib/token-measurement.js +126 -0
- package/lib/tools.js +101 -6
- package/lib/turn-log.js +108 -3
- package/lib/webui/graph-layout-worker.js +68 -0
- package/lib/webui/graph-local-physics.js +390 -0
- package/lib/webui/graph-spatial-grid.js +64 -0
- package/lib/webui/graph-view.bundle.js +6 -1
- package/lib/webui/graph-view.js +478 -135
- package/lib/webui/graph-webgl-renderer.js +74 -0
- package/lib/webui/standalone.js +1 -1
- package/lib/worker-pool.js +38 -7
- package/package.json +3 -2
- package/scripts/acceptance-local.mjs +4 -10
- package/scripts/bench-all-libraries.mjs +47 -0
- package/scripts/check-classic-graph-browser.mjs +189 -0
- package/scripts/check-client-browser.mjs +929 -0
- package/scripts/check-graph-browser.mjs +6 -0
- package/scripts/check-graph-elastic-browser.mjs +139 -0
- package/scripts/check-memory-review-browser.mjs +124 -0
- package/scripts/entity-dedupe.mjs +19 -3
- package/scripts/graph-artifact-provenance.mjs +30 -0
- package/scripts/graph-freeze-manifest.mjs +129 -0
- package/scripts/graph-geometry-fixture.mjs +40 -0
- package/scripts/graph-physics-bench.mjs +218 -0
- package/scripts/graph-scale-bench.mjs +213 -0
- package/scripts/graph-scale-memory.mjs +48 -0
- package/scripts/graph-service-bench.mjs +72 -0
- package/scripts/make-readme-shots.mjs +17 -5
- package/scripts/preview.mjs +1 -0
- package/scripts/rebuild-rt.mjs +18 -0
- package/scripts/scale-bench.mjs +183 -0
- package/scripts/simulate-injection.mjs +47 -8
- package/scripts/verify-host-fixtures.mjs +108 -0
- package/scripts/verify-host-recovery.mjs +565 -0
- package/scripts/verify-vector-recovery.mjs +740 -0
- package/tests/auto-link-candidates.test.mjs +20 -0
- package/tests/browser.test.mjs +16 -2
- package/tests/client-export.test.mjs +16 -1
- package/tests/client-pagination.test.mjs +1495 -0
- package/tests/client-render.test.mjs +223 -28
- package/tests/consolidation-fork.test.mjs +97 -13
- package/tests/consolidation-ledger.test.mjs +17 -1
- package/tests/diagnostic-entity-candidates.test.mjs +54 -0
- package/tests/diagnostic-report.test.mjs +429 -0
- package/tests/diagnostic-wiring.test.mjs +88 -0
- package/tests/diagnostics.test.mjs +27 -0
- package/tests/embedding-download.test.mjs +44 -0
- package/tests/engine-source-settings.test.mjs +69 -0
- package/tests/engine-sources.test.mjs +145 -0
- package/tests/entity-dedupe.test.mjs +143 -0
- package/tests/entity-merge-review.test.mjs +363 -0
- package/tests/entity-merge.test.mjs +12 -4
- package/tests/entity-review.test.mjs +87 -0
- package/tests/environment-check.test.mjs +51 -1
- package/tests/feedback.test.mjs +95 -0
- package/tests/graph-adjacency-index.test.mjs +536 -0
- package/tests/graph-cascade.test.mjs +229 -0
- package/tests/graph-import-diagnostic.test.mjs +25 -0
- package/tests/graph-overview.test.mjs +709 -0
- package/tests/graph-session-authorization.test.mjs +419 -0
- package/tests/graph-view-geometry.test.mjs +426 -0
- package/tests/graph-view-scale.test.mjs +88 -0
- package/tests/graph-view.test.mjs +444 -5
- package/tests/graph.test.mjs +43 -0
- package/tests/help-page.test.mjs +128 -54
- package/tests/inbound.test.mjs +19 -0
- package/tests/index-pagination.test.mjs +113 -0
- package/tests/index-read-view.test.mjs +212 -0
- package/tests/inject-guide.test.mjs +9 -0
- package/tests/injection-dedupe.test.mjs +213 -0
- package/tests/lexicon-recall.test.mjs +641 -0
- package/tests/lexicon-rt-lifecycle.test.mjs +196 -0
- package/tests/lexicon-rt.test.mjs +468 -0
- package/tests/local-embedding-worker.test.mjs +38 -0
- package/tests/local-vector-service.test.mjs +32 -3
- package/tests/maintenance-compat.test.mjs +128 -0
- package/tests/maintenance-settlement.test.mjs +1003 -0
- package/tests/managed-memory.test.mjs +39 -11
- package/tests/managed-runtime.test.mjs +109 -0
- package/tests/memory-fields.test.mjs +24 -12
- package/tests/observed-evidence.test.mjs +52 -0
- package/tests/port-surface.test.mjs +93 -1
- package/tests/preset-mount.test.mjs +12 -4
- package/tests/recall-cache.test.mjs +56 -3
- package/tests/recall-dedup.test.mjs +63 -2
- package/tests/retention.test.mjs +260 -0
- package/tests/rt-index-cross-library.test.mjs +230 -0
- package/tests/rt-index-integration.test.mjs +194 -0
- package/tests/rt-index-retention.test.mjs +552 -0
- package/tests/rt-index-scale.test.mjs +204 -0
- package/tests/rt-index.test.mjs +705 -0
- package/tests/salient-date-boundaries.test.mjs +121 -0
- package/tests/salient-wake.test.mjs +29 -0
- package/tests/scale-bench.test.mjs +53 -0
- package/tests/settings-plumbing.test.mjs +25 -0
- package/tests/simulate-injection.test.mjs +15 -1
- package/tests/standalone-navigation.test.mjs +44 -0
- package/tests/state.test.mjs +51 -0
- package/tests/temporal-precision.test.mjs +102 -0
- package/tests/temporal.test.mjs +10 -6
- package/tests/token-measurement.test.mjs +98 -0
- package/tests/tool-schema.test.mjs +41 -5
- package/tests/tools.test.mjs +6 -3
- package/tests/turn-token-budget.test.mjs +149 -0
- package/tests/webui-auth.test.mjs +57 -1
- package/tests/webui.test.mjs +40 -15
- package/tests/worker-lifecycle.test.mjs +2 -1
|
@@ -0,0 +1,740 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Real, offline managed-local QA. Production files are read only as bytes.
|
|
3
|
+
import fs from 'node:fs'
|
|
4
|
+
import path from 'node:path'
|
|
5
|
+
import crypto from 'node:crypto'
|
|
6
|
+
import http from 'node:http'
|
|
7
|
+
import assert from 'node:assert/strict'
|
|
8
|
+
import os from 'node:os'
|
|
9
|
+
import childProcess, { spawn, execFileSync } from 'node:child_process'
|
|
10
|
+
import { createRequire, registerHooks, syncBuiltinESMExports } from 'node:module'
|
|
11
|
+
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
12
|
+
import { DatabaseSync } from 'node:sqlite'
|
|
13
|
+
|
|
14
|
+
const repo = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
|
|
15
|
+
const options = Object.fromEntries(process.argv.slice(2).map(arg => {
|
|
16
|
+
const at = arg.indexOf('=')
|
|
17
|
+
return [arg.slice(2, at < 0 ? undefined : at), at < 0 ? true : arg.slice(at + 1)]
|
|
18
|
+
}))
|
|
19
|
+
const hash = value => crypto.createHash('sha256').update(value).digest('hex')
|
|
20
|
+
const read = file => JSON.parse(fs.readFileSync(file, 'utf8'))
|
|
21
|
+
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
|
|
22
|
+
const inside = (root, file) => path.resolve(file).startsWith(path.resolve(root) + path.sep)
|
|
23
|
+
const json = value => JSON.stringify(value, null, 2) + '\r\n'
|
|
24
|
+
const list = (root, prefix = '') => fs.readdirSync(root, { withFileTypes: true }).flatMap(item => {
|
|
25
|
+
assert.ok(!item.isSymbolicLink(), 'symlink not admitted')
|
|
26
|
+
const relative = path.join(prefix, item.name)
|
|
27
|
+
return item.isDirectory() ? list(path.join(root, item.name), relative) : [relative]
|
|
28
|
+
}).sort()
|
|
29
|
+
const inventory = root => list(root).map(file => {
|
|
30
|
+
const bytes = fs.readFileSync(path.join(root, file))
|
|
31
|
+
return { file: file.replaceAll('\\', '/'), bytes: bytes.length, sha256: hash(bytes) }
|
|
32
|
+
})
|
|
33
|
+
const copyVerifiedTree = (source, destination, run) => {
|
|
34
|
+
source = fs.realpathSync(source)
|
|
35
|
+
destination = path.resolve(destination)
|
|
36
|
+
assert.ok(inside(run, destination), 'artifact copy must stay inside isolated run')
|
|
37
|
+
fs.mkdirSync(path.dirname(destination), { recursive: true })
|
|
38
|
+
fs.cpSync(source, destination, { recursive: true, errorOnExist: true, force: false, dereference: false })
|
|
39
|
+
const sourceFiles = inventory(source)
|
|
40
|
+
assert.deepEqual(inventory(destination), sourceFiles, `isolated artifact copy differs: ${path.basename(source)}`)
|
|
41
|
+
return { source, destination: fs.realpathSync(destination), files: sourceFiles.length,
|
|
42
|
+
bytes: sourceFiles.reduce((sum, item) => sum + item.bytes, 0), inventorySha256: hash(JSON.stringify(sourceFiles)) }
|
|
43
|
+
}
|
|
44
|
+
const relocateVenvConfig = (venv, basePython) => {
|
|
45
|
+
const file = path.join(venv, 'pyvenv.cfg')
|
|
46
|
+
const source = fs.readFileSync(file, 'utf8')
|
|
47
|
+
const replacements = new Map([['home', path.dirname(basePython)], ['executable', basePython]])
|
|
48
|
+
const found = new Set()
|
|
49
|
+
const relocated = source.replace(/^([A-Za-z][A-Za-z0-9_-]*)\s*=\s*(.*)$/gm, (line, key) => {
|
|
50
|
+
if (!replacements.has(key)) return line
|
|
51
|
+
found.add(key)
|
|
52
|
+
return `${key} = ${replacements.get(key)}`
|
|
53
|
+
})
|
|
54
|
+
assert.deepEqual([...found].sort(), [...replacements.keys()].sort(), 'venv config must contain its base Python paths')
|
|
55
|
+
fs.writeFileSync(file, relocated, 'utf8')
|
|
56
|
+
}
|
|
57
|
+
const sourceManifest = root => [
|
|
58
|
+
...['lib', 'assets'].flatMap(directory => list(path.join(root, directory)).map(relative => {
|
|
59
|
+
const file = path.join(directory, relative)
|
|
60
|
+
const bytes = fs.readFileSync(path.join(root, file))
|
|
61
|
+
return { file: file.replaceAll('\\', '/'), sha256: hash(bytes), bytes: bytes.length }
|
|
62
|
+
})),
|
|
63
|
+
...['package.json', 'cordis.patch.yml'].map(file => {
|
|
64
|
+
const bytes = fs.readFileSync(path.join(root, file))
|
|
65
|
+
return { file, sha256: hash(bytes), bytes: bytes.length }
|
|
66
|
+
}),
|
|
67
|
+
].sort((a, b) => a.file.localeCompare(b.file))
|
|
68
|
+
const compareSourceManifests = (expected, actual) => {
|
|
69
|
+
const before = new Map(expected.map(item => [item.file, item.sha256]))
|
|
70
|
+
const after = new Map(actual.map(item => [item.file, item.sha256]))
|
|
71
|
+
const added = [...after.keys()].filter(file => !before.has(file)).sort()
|
|
72
|
+
const removed = [...before.keys()].filter(file => !after.has(file)).sort()
|
|
73
|
+
const changed = [...before.keys()].filter(file => after.has(file) && before.get(file) !== after.get(file)).sort()
|
|
74
|
+
return { matches: added.length === 0 && removed.length === 0 && changed.length === 0, added, removed, changed }
|
|
75
|
+
}
|
|
76
|
+
const assertGenerationDatabasesIsolated = (data, generation, expected) => {
|
|
77
|
+
const expectedLibraries = expected.libraries || Object.fromEntries(
|
|
78
|
+
Object.entries(expected).filter(([key]) => key !== 'global')
|
|
79
|
+
)
|
|
80
|
+
assert.ok(inside(data, generation.global), 'global vector database must be inside isolated data')
|
|
81
|
+
assert.equal(path.resolve(generation.global), path.resolve(data, expected.global), 'global vector database must match its copied fixture')
|
|
82
|
+
assert.deepEqual(Object.keys(generation.libraries || {}).sort(), Object.keys(expectedLibraries).sort(),
|
|
83
|
+
'active private vector database set must match copied fixtures')
|
|
84
|
+
for (const [libraryId, file] of Object.entries(generation.libraries || {})) {
|
|
85
|
+
assert.ok(inside(data, file), `private vector database ${libraryId} must be inside isolated data`)
|
|
86
|
+
assert.equal(path.resolve(file), path.resolve(data, expectedLibraries[libraryId]),
|
|
87
|
+
`private vector database ${libraryId} must match its copied fixture`)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const managerIsStopped = status => status?.closed === true && status.running === 0 && status.booting === 0
|
|
91
|
+
const waitForChildClose = (child, timeoutMs) => new Promise(resolve => {
|
|
92
|
+
if (child.exitCode !== null || child.signalCode !== null) return resolve({ closed: true })
|
|
93
|
+
let settled = false
|
|
94
|
+
const finish = value => {
|
|
95
|
+
if (settled) return
|
|
96
|
+
settled = true
|
|
97
|
+
clearTimeout(timer)
|
|
98
|
+
child.removeListener('close', onClose)
|
|
99
|
+
resolve(value)
|
|
100
|
+
}
|
|
101
|
+
const onClose = (code, signal) => finish({ closed: true, code, signal })
|
|
102
|
+
const timer = setTimeout(() => finish({ closed: false, timedOut: true }), timeoutMs)
|
|
103
|
+
child.once('close', onClose)
|
|
104
|
+
})
|
|
105
|
+
async function terminateOwnedTree(child, protectedPid) {
|
|
106
|
+
if (!child?.pid || child.pid === protectedPid) throw new Error('refusing to terminate an unidentified or protected process')
|
|
107
|
+
if (child.exitCode !== null || child.signalCode !== null) return { closed: true, alreadyExited: true }
|
|
108
|
+
let treeTermination = null
|
|
109
|
+
if (process.platform === 'win32') {
|
|
110
|
+
const result = childProcess.spawnSync('taskkill.exe', ['/PID', String(child.pid), '/T', '/F'], {
|
|
111
|
+
windowsHide: true, stdio: 'ignore', timeout: 10_000,
|
|
112
|
+
})
|
|
113
|
+
treeTermination = { status: result.status, signal: result.signal, errorCode: result.error?.code }
|
|
114
|
+
} else child.kill('SIGTERM')
|
|
115
|
+
let closed = await waitForChildClose(child, 5_000)
|
|
116
|
+
if (!closed.closed) {
|
|
117
|
+
try { child.kill('SIGKILL') } catch {}
|
|
118
|
+
closed = await waitForChildClose(child, 5_000)
|
|
119
|
+
}
|
|
120
|
+
return { ...closed, treeTermination }
|
|
121
|
+
}
|
|
122
|
+
const identity = pid => JSON.parse(execFileSync('powershell.exe', ['-NoProfile', '-Command',
|
|
123
|
+
`$p=Get-Process -Id ${Number(pid)} -ErrorAction Stop; @{pid=$p.Id; name=$p.ProcessName; started=$p.StartTime.ToUniversalTime().ToString('o')} | ConvertTo-Json -Compress`],
|
|
124
|
+
{ windowsHide: true, encoding: 'utf8' }))
|
|
125
|
+
|
|
126
|
+
function peerResolution(hostAnchor) {
|
|
127
|
+
const anchors = [hostAnchor, path.join(repo, 'package.json')].map(file => createRequire(file))
|
|
128
|
+
const resolving = new Set()
|
|
129
|
+
registerHooks({ resolve(specifier, context, next) {
|
|
130
|
+
try { return next(specifier, context) } catch (error) {
|
|
131
|
+
if (error.code !== 'ERR_MODULE_NOT_FOUND' || specifier.startsWith('.') || specifier.startsWith('/') || specifier.includes(':') || resolving.has(specifier)) throw error
|
|
132
|
+
resolving.add(specifier)
|
|
133
|
+
try {
|
|
134
|
+
for (const anchor of anchors) {
|
|
135
|
+
try { return next(pathToFileURL(anchor.resolve(specifier)).href, context) } catch {}
|
|
136
|
+
}
|
|
137
|
+
throw error
|
|
138
|
+
} finally { resolving.delete(specifier) }
|
|
139
|
+
}
|
|
140
|
+
} })
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async function child(run) {
|
|
144
|
+
run = fs.realpathSync(run)
|
|
145
|
+
assert.ok(inside(path.join(repo, 'logs'), run) && path.basename(run).startsWith('recovery-vector-'))
|
|
146
|
+
const config = read(path.join(run, 'fixture-config.json'))
|
|
147
|
+
const data = path.join(run, 'home/dsh-memu-memory')
|
|
148
|
+
assert.equal(path.resolve(process.env.DSH_MEMU_MEMORY_HOME || ''), data)
|
|
149
|
+
process.chdir(run)
|
|
150
|
+
peerResolution(config.hostAnchor)
|
|
151
|
+
const owned = new Set(), processRecords = []
|
|
152
|
+
const nativeSpawn = childProcess.spawn
|
|
153
|
+
childProcess.spawn = (...args) => {
|
|
154
|
+
const handle = nativeSpawn(...args)
|
|
155
|
+
owned.add(handle)
|
|
156
|
+
const record = { pid: handle.pid, executable: path.basename(args[0]), startedAt: new Date().toISOString(), closed: false }
|
|
157
|
+
processRecords.push(record)
|
|
158
|
+
const save = () => fs.writeFileSync(path.join(run, 'owned-processes.json'), json(processRecords), { mode: 0o600 })
|
|
159
|
+
save()
|
|
160
|
+
handle.once('close', code => { owned.delete(handle); record.closed = true; record.exitCode = code; save() })
|
|
161
|
+
return handle
|
|
162
|
+
}
|
|
163
|
+
syncBuiltinESMExports()
|
|
164
|
+
const source = file => import(pathToFileURL(path.join(run, 'plugin/lib', file)).href)
|
|
165
|
+
const { privateRecall, readMemoryByRef } = await source('memory.js')
|
|
166
|
+
const state = await source('state.js')
|
|
167
|
+
const { activeProfile, captureGeneration } = await source('vector-profile.js')
|
|
168
|
+
const memu = await source('memu.js')
|
|
169
|
+
const workers = await source('local-embedding-manager.js')
|
|
170
|
+
const { modelIdForRole } = await source('local-embedding-protocol.js')
|
|
171
|
+
const { recallCache } = await source('recall-cache.js')
|
|
172
|
+
const paths = await source('paths.js')
|
|
173
|
+
const results = { schema: 1, ok: false, checks: [], embeddings: [], retrieves: [], recalls: [],
|
|
174
|
+
instrumentation: 'pass-through HTTP observer and retrieve decorator; no stub results or model',
|
|
175
|
+
worker: {}, warnings: [] }
|
|
176
|
+
const write = () => fs.writeFileSync(path.join(run, 'vector-results.json'), json(results), { mode: 0o600 })
|
|
177
|
+
const check = (name, ok, detail = {}) => {
|
|
178
|
+
results.checks.push({ name, ok: Boolean(ok), ...detail }); write()
|
|
179
|
+
assert.ok(ok, name)
|
|
180
|
+
}
|
|
181
|
+
paths.setWarnSink(message => results.warnings.push({ code: String(message).match(/\b(?:VECTOR|LOCAL_VECTOR|MEMU)_[A-Z_]+\b/)?.[0] || 'WARNING', messageSha256: hash(String(message)) }))
|
|
182
|
+
const manager = workers.embeddingWorkerManager()
|
|
183
|
+
let server
|
|
184
|
+
let currentCase = 'startup'
|
|
185
|
+
const summarize = file => ({ id: file.name, libraryId: file.libraryId || file.ref?.libraryId || null,
|
|
186
|
+
score: file.score ?? null, retrievalScore: file.retrievalScore ?? null,
|
|
187
|
+
semanticScore: file.fusion?.semanticScore ?? null, semanticRank: file.fusion?.semanticRank ?? null,
|
|
188
|
+
lexicalRank: file.fusion?.localRank ?? null, rrf: file.fusion?.rrf ?? null,
|
|
189
|
+
routes: file.fusion?.routes || [] })
|
|
190
|
+
try {
|
|
191
|
+
const profile = activeProfile()
|
|
192
|
+
check('active-profile-space-preserved', profile.fingerprint === config.fingerprint && profile.catalogId === config.catalogId)
|
|
193
|
+
check('managed-local-selected', state.effectiveVectorRoute() === 'managed-local')
|
|
194
|
+
const generation = captureGeneration()
|
|
195
|
+
assertGenerationDatabasesIsolated(data, generation, config.databases)
|
|
196
|
+
check('active-generation-databases-isolated', true, {
|
|
197
|
+
libraries: Object.keys(generation.libraries).length,
|
|
198
|
+
global: path.relative(data, generation.global),
|
|
199
|
+
})
|
|
200
|
+
const endpoint = await manager.acquire(profile)
|
|
201
|
+
results.worker = { ...manager.status(), model: endpoint.model, dimension: profile.dimension,
|
|
202
|
+
rolesRequired: endpoint.rolesRequired === true, loopback: new URL(endpoint.baseUrl).hostname === '127.0.0.1' }
|
|
203
|
+
check('real-native-worker-ready', results.worker.running === 1 && results.worker.loopback && profile.dimension === config.dimension)
|
|
204
|
+
|
|
205
|
+
// Forward bytes unchanged to the real worker; retain only hashes and dimensions.
|
|
206
|
+
server = http.createServer((request, response) => {
|
|
207
|
+
const chunks = []
|
|
208
|
+
request.on('data', chunk => chunks.push(chunk))
|
|
209
|
+
request.on('end', () => {
|
|
210
|
+
const payload = Buffer.concat(chunks)
|
|
211
|
+
let body
|
|
212
|
+
try { body = JSON.parse(payload) } catch { response.writeHead(400); response.end(); return }
|
|
213
|
+
const inputs = Array.isArray(body.input) ? body.input : [body.input]
|
|
214
|
+
const trace = { case: currentCase, route: 'managed-local', path: request.url, model: body.model,
|
|
215
|
+
inputSha256: hash(JSON.stringify(inputs)), inputCount: inputs.length,
|
|
216
|
+
inputChars: inputs.reduce((sum, item) => sum + String(item).length, 0), status: null }
|
|
217
|
+
results.embeddings.push(trace)
|
|
218
|
+
const url = new URL(request.url, endpoint.baseUrl)
|
|
219
|
+
assert.equal(url.hostname, '127.0.0.1')
|
|
220
|
+
const upstream = http.request(url, { method: request.method, headers: {
|
|
221
|
+
'content-type': 'application/json', authorization: request.headers.authorization,
|
|
222
|
+
'content-length': payload.length } }, res => {
|
|
223
|
+
const returned = []
|
|
224
|
+
res.on('data', chunk => returned.push(chunk))
|
|
225
|
+
res.on('end', () => {
|
|
226
|
+
const bytes = Buffer.concat(returned)
|
|
227
|
+
trace.status = res.statusCode
|
|
228
|
+
try {
|
|
229
|
+
const parsed = JSON.parse(bytes)
|
|
230
|
+
trace.dimensions = (parsed.data || []).map(item => typeof item.embedding === 'string'
|
|
231
|
+
? Buffer.from(item.embedding, 'base64').length / 4 : item.embedding?.length)
|
|
232
|
+
trace.responseSha256 = hash(bytes)
|
|
233
|
+
} catch { trace.invalidJson = true }
|
|
234
|
+
response.writeHead(res.statusCode, { 'content-type': 'application/json' }); response.end(bytes)
|
|
235
|
+
})
|
|
236
|
+
})
|
|
237
|
+
upstream.on('error', error => { trace.errorCode = error.code; response.writeHead(502); response.end() })
|
|
238
|
+
upstream.end(payload)
|
|
239
|
+
})
|
|
240
|
+
})
|
|
241
|
+
await new Promise(resolve => server.listen(0, '127.0.0.1', resolve))
|
|
242
|
+
const observed = { ...endpoint, baseUrl: `http://127.0.0.1:${server.address().port}/v1` }
|
|
243
|
+
manager.acquire = async supplied => {
|
|
244
|
+
assert.equal(supplied.fingerprint, profile.fingerprint)
|
|
245
|
+
assert.equal(supplied.modelDir, profile.modelDir)
|
|
246
|
+
assert.equal(supplied.runtimeDir, profile.runtimeDir)
|
|
247
|
+
return observed
|
|
248
|
+
}
|
|
249
|
+
const embed = async (input, role) => {
|
|
250
|
+
const response = await fetch(new URL('/v1/embeddings', observed.baseUrl), {
|
|
251
|
+
method: 'POST', headers: { 'content-type': 'application/json', authorization: `Bearer ${endpoint.token}` },
|
|
252
|
+
body: JSON.stringify({ model: modelIdForRole(endpoint.model, role), input, encoding_format: 'float' }),
|
|
253
|
+
signal: AbortSignal.timeout(60000) })
|
|
254
|
+
assert.equal(response.status, 200)
|
|
255
|
+
const vector = (await response.json()).data[0].embedding
|
|
256
|
+
assert.equal(vector.length, profile.dimension)
|
|
257
|
+
assert.ok(vector.every(Number.isFinite))
|
|
258
|
+
return vector
|
|
259
|
+
}
|
|
260
|
+
currentCase = 'real-embedding-nonlexical-sanity'
|
|
261
|
+
const first = await embed('The launch has been moved to Friday.', 'query')
|
|
262
|
+
const near = await embed('The release date was postponed until Friday.', 'document')
|
|
263
|
+
const far = await embed('A dolphin swims in the deep ocean.', 'document')
|
|
264
|
+
const cosine = (a, b) => a.reduce((sum, value, i) => sum + value * b[i], 0) /
|
|
265
|
+
(Math.hypot(...a) * Math.hypot(...b))
|
|
266
|
+
const nearScore = cosine(first, near), farScore = cosine(first, far)
|
|
267
|
+
check('real-embedding-semantic-order', nearScore > farScore + 0.03, { dimension: first.length, nearScore, farScore,
|
|
268
|
+
queryVectorSha256: hash(Buffer.from(new Float32Array(first).buffer)), model: endpoint.model })
|
|
269
|
+
const retrieve = async args => {
|
|
270
|
+
assert.equal(args.route, 'managed-local')
|
|
271
|
+
assert.ok(inside(data, args.db), 'MemU database must be isolated')
|
|
272
|
+
const start = results.embeddings.length
|
|
273
|
+
const entry = { case: currentCase, route: args.route, db: path.relative(data, args.db),
|
|
274
|
+
querySha256: hash(String(args.query)), startedAt: new Date().toISOString() }
|
|
275
|
+
results.retrieves.push(entry)
|
|
276
|
+
try {
|
|
277
|
+
const value = await memu.retrieve(args)
|
|
278
|
+
entry.files = (value.files || []).map(summarize)
|
|
279
|
+
entry.embeddingRequests = results.embeddings.length - start
|
|
280
|
+
entry.parseWarning = Boolean(value.parseWarning)
|
|
281
|
+
assert.ok(entry.embeddingRequests > 0, 'real retrieve must call native embedding')
|
|
282
|
+
assert.ok(entry.files.some(file => Number.isFinite(file.score)), 'retrieve must return real similarity scores')
|
|
283
|
+
return value
|
|
284
|
+
} catch (error) { entry.errorCode = error.code || error.name; throw error }
|
|
285
|
+
finally { entry.finishedAt = new Date().toISOString(); write() }
|
|
286
|
+
}
|
|
287
|
+
const execFor = fixture => ({ agent: { id: fixture.sessionId, session: { header: { id: fixture.sessionId } } } })
|
|
288
|
+
const recall = async (name, fixture, query, { cross = false, purpose = 'automatic', unbound = false } = {}) => {
|
|
289
|
+
currentCase = name
|
|
290
|
+
recallCache.bumpGeneration()
|
|
291
|
+
const start = results.retrieves.length
|
|
292
|
+
const value = await privateRecall({ ...(unbound ? { libraryId: fixture.libraryId } : { exec: execFor(fixture) }), query, purpose, topK: 20,
|
|
293
|
+
relevanceThreshold: 0, retrieveImpl: retrieve })
|
|
294
|
+
const row = { case: name, querySha256: hash(query), recallRoute: value.recallRoute,
|
|
295
|
+
libraries: value.libraries || [fixture.libraryId], files: value.files.map(summarize),
|
|
296
|
+
retrievalCalls: results.retrieves.length - start, errorCount: value.errors?.length || 0,
|
|
297
|
+
fusion: value.fusion || null }
|
|
298
|
+
results.recalls.push(row); write()
|
|
299
|
+
check(name + ':native-route', row.retrievalCalls > 0 && row.errorCount === 0 && row.recallRoute === (cross ? 'cross-library' : 'managed-vector-rrf'),
|
|
300
|
+
{ recallRoute: row.recallRoute, retrievalCalls: row.retrievalCalls, errorCount: row.errorCount })
|
|
301
|
+
check(name + ':semantic-files', row.files.some(file => Number.isFinite(file.semanticScore) && file.semanticRank > 0))
|
|
302
|
+
return row
|
|
303
|
+
}
|
|
304
|
+
const fixtures = config.fixtures
|
|
305
|
+
state.updateSettings({ crossLibraryRecall: false })
|
|
306
|
+
for (const fixture of fixtures) {
|
|
307
|
+
const index = state.readPrivateIndex(fixture.libraryId)
|
|
308
|
+
let matched
|
|
309
|
+
// Every attempted candidate is retained, including misses; never choose a mock hit.
|
|
310
|
+
for (const id of fixture.candidateIds.slice(0, 5)) {
|
|
311
|
+
currentCase = 'real-id-probe:' + fixture.libraryId + ':' + id
|
|
312
|
+
const query = index.entries[id].title
|
|
313
|
+
const semantic = await retrieve({ query, db: captureGeneration().libraries[fixture.libraryId], route: 'managed-local', timeoutMs: 60000 })
|
|
314
|
+
const found = semantic.files?.find(file => file.name.replace(/\.md$/i, '') === id && Number.isFinite(file.score))
|
|
315
|
+
if (found) { matched = { id, query, score: found.score }; break }
|
|
316
|
+
}
|
|
317
|
+
check('real-source-id-in-vector:' + fixture.libraryId, Boolean(matched), { attemptedCandidates: fixture.candidateIds.slice(0, 5) })
|
|
318
|
+
fixture.id = matched.id
|
|
319
|
+
const row = await recall('single:' + fixture.domain + ':' + fixture.libraryId, fixture, matched.query)
|
|
320
|
+
check('actual-original-id:' + fixture.libraryId, row.files.some(file => file.id === fixture.id && Number.isFinite(file.semanticScore)),
|
|
321
|
+
{ expectedId: fixture.id, vectorScore: matched.score, actualIds: row.files.map(file => file.id) })
|
|
322
|
+
}
|
|
323
|
+
const primary = fixtures[0], foreign = fixtures[1], otherDomain = fixtures[2]
|
|
324
|
+
state.updateSettings({ crossLibraryRecall: true })
|
|
325
|
+
const queryOf = fixture => state.readPrivateIndex(fixture.libraryId).entries[fixture.id].title
|
|
326
|
+
const cross = await recall('same-domain-cross-library', primary, queryOf(foreign), { cross: true })
|
|
327
|
+
check('same-domain-foreign-actual-id', cross.files.some(file => file.id === foreign.id && file.libraryId === foreign.libraryId && Number.isFinite(file.semanticScore)),
|
|
328
|
+
{ expectedId: foreign.id, expectedLibraryId: foreign.libraryId })
|
|
329
|
+
check('same-domain-comparable-semantic-scores', cross.fusion?.crossLibrarySemantic === 'score')
|
|
330
|
+
const isolated = await recall('cross-domain-private', primary, queryOf(otherDomain), { cross: true })
|
|
331
|
+
check('cross-domain-library-never-queried', !isolated.libraries.includes(otherDomain.libraryId) && !isolated.files.some(file => file.id === otherDomain.id),
|
|
332
|
+
{ forbiddenId: otherDomain.id, libraries: isolated.libraries })
|
|
333
|
+
assert.throws(() => readMemoryByRef({ exec: execFor(primary), id: otherDomain.id, libraryId: otherDomain.libraryId }),
|
|
334
|
+
error => error.code === 'MEMORY_LIBRARY_FORBIDDEN')
|
|
335
|
+
check('cross-domain-body-denied', true)
|
|
336
|
+
|
|
337
|
+
// Keep real vector rows/IDs; mutate only eligibility metadata in the isolated truth index.
|
|
338
|
+
const savedEntry = structuredClone(state.readPrivateIndex(foreign.libraryId).entries[foreign.id])
|
|
339
|
+
const patch = values => {
|
|
340
|
+
state.updatePrivateIndex(foreign.libraryId, index => { Object.assign(index.entries[foreign.id], values) })
|
|
341
|
+
recallCache.bumpGeneration()
|
|
342
|
+
}
|
|
343
|
+
const assertFiltered = async (name, fixture, expectedAbsent) => {
|
|
344
|
+
const row = await recall(name, fixture, queryOf(foreign), { cross: true })
|
|
345
|
+
const calls = results.retrieves.filter(item => item.case === name && item.db.replaceAll('\\', '/') === config.databases[foreign.libraryId])
|
|
346
|
+
check(name + ':vector-candidate-was-present', calls.some(item => item.files?.some(file => file.id.replace(/\.md$/i, '') === foreign.id)))
|
|
347
|
+
check(name + ':privacy-gate', row.files.some(file => file.id === foreign.id && file.libraryId === foreign.libraryId) !== expectedAbsent,
|
|
348
|
+
{ actualOriginalId: foreign.id })
|
|
349
|
+
return row
|
|
350
|
+
}
|
|
351
|
+
try {
|
|
352
|
+
patch({ visibility: 'secret' })
|
|
353
|
+
await assertFiltered('secret-automatic-cross-library', primary, true)
|
|
354
|
+
const secretExplicit = await recall('secret-explicit-bound', foreign, queryOf(foreign), { purpose: 'explicit', cross: true })
|
|
355
|
+
check('secret-explicit-bound-original-id', secretExplicit.files.some(file => file.id === foreign.id && Number.isFinite(file.semanticScore)))
|
|
356
|
+
const unbound = await recall('secret-explicit-unbound', foreign, queryOf(foreign), { purpose: 'explicit', unbound: true })
|
|
357
|
+
check('secret-unbound-original-id-denied', !unbound.files.some(file => file.id === foreign.id))
|
|
358
|
+
state.setSessionBinding(primary.sessionId, { memoryContext: { characterId: 'recovery-vector-current', worldId: 'recovery-vector-world' } })
|
|
359
|
+
patch({ visibility: 'shared', context: { characterId: 'recovery-vector-other', worldId: 'recovery-vector-world' } })
|
|
360
|
+
await assertFiltered('context-mismatch-cross-library', primary, true)
|
|
361
|
+
assert.throws(() => readMemoryByRef({ exec: execFor(primary), id: foreign.id, libraryId: foreign.libraryId }),
|
|
362
|
+
error => error.code === 'MEMORY_NOT_READABLE')
|
|
363
|
+
check('context-mismatch-body-denied', true)
|
|
364
|
+
state.setSessionBinding(primary.sessionId, { memoryContext: { characterId: 'recovery-vector-other', worldId: 'recovery-vector-world' } })
|
|
365
|
+
await assertFiltered('context-match-cross-library', primary, false)
|
|
366
|
+
patch({ domain: otherDomain.domain, context: {} })
|
|
367
|
+
await assertFiltered('foreign-entry-domain-in-same-library', primary, true)
|
|
368
|
+
} finally {
|
|
369
|
+
state.updatePrivateIndex(foreign.libraryId, index => { index.entries[foreign.id] = savedEntry })
|
|
370
|
+
state.setSessionBinding(primary.sessionId, { memoryContext: {} })
|
|
371
|
+
}
|
|
372
|
+
check('all-embedding-requests-real-and-successful', results.embeddings.length > 3 && results.embeddings.every(item =>
|
|
373
|
+
item.path === '/v1/embeddings' && item.status === 200 && item.dimensions?.every(value => value === profile.dimension)),
|
|
374
|
+
{ requests: results.embeddings.length })
|
|
375
|
+
check('no-lexical-fallback-or-mock', results.recalls.length >= 8 && results.recalls.every(item => item.errorCount === 0 &&
|
|
376
|
+
['managed-vector-rrf', 'cross-library'].includes(item.recallRoute)) && results.retrieves.every(item => !item.errorCode && item.embeddingRequests > 0))
|
|
377
|
+
results.fixtures = fixtures.map(({ candidateIds, ...fixture }) => fixture)
|
|
378
|
+
results.ok = true
|
|
379
|
+
} catch (error) {
|
|
380
|
+
results.failure = { code: error.code || error.name, messageSha256: hash(String(error.message)),
|
|
381
|
+
assertion: results.checks.findLast(item => !item.ok)?.name || null, case: currentCase,
|
|
382
|
+
frames: String(error.stack || '').split('\n').filter(line => /^\s+at /.test(line)).slice(0, 6) }
|
|
383
|
+
process.exitCode = 1
|
|
384
|
+
} finally {
|
|
385
|
+
const cleanupErrors = []
|
|
386
|
+
const cleanup = async (stage, action) => {
|
|
387
|
+
try { await action() } catch (error) {
|
|
388
|
+
cleanupErrors.push({ stage, code: error.code || error.name || 'ERROR', messageSha256: hash(String(error.message || error)) })
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
await cleanup('memu-resident-close', () => memu.closeMemuResident())
|
|
392
|
+
await cleanup('embedding-worker-close', () => workers.closeEmbeddingWorkers())
|
|
393
|
+
await cleanup('state-flush', () => state.flushState())
|
|
394
|
+
if (server) await cleanup('observer-close', () => new Promise((resolve, reject) => {
|
|
395
|
+
server.close(error => error ? reject(error) : resolve())
|
|
396
|
+
server.closeAllConnections?.()
|
|
397
|
+
}))
|
|
398
|
+
for (const handle of owned) await cleanup('owned-child-kill', () => { handle.kill() })
|
|
399
|
+
for (let i = 0; owned.size && i < 50; i++) await sleep(100)
|
|
400
|
+
results.ownedProcessesClosed = owned.size === 0
|
|
401
|
+
results.workerAfterClose = manager.status()
|
|
402
|
+
const terminal = managerIsStopped(results.workerAfterClose)
|
|
403
|
+
results.checks.push({ name: 'owned-processes-closed', ok: results.ownedProcessesClosed })
|
|
404
|
+
results.checks.push({ name: 'embedding-manager-terminal', ok: terminal, status: results.workerAfterClose })
|
|
405
|
+
results.cleanupErrors = cleanupErrors
|
|
406
|
+
if (!results.ownedProcessesClosed || !terminal || cleanupErrors.length) {
|
|
407
|
+
results.ok = false
|
|
408
|
+
process.exitCode = 1
|
|
409
|
+
}
|
|
410
|
+
try { write() } catch (error) {
|
|
411
|
+
process.stderr.write(`Unable to persist vector QA report (${error.code || error.name || 'ERROR'}).\n`)
|
|
412
|
+
process.exitCode = 1
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
console.log(JSON.stringify({ ok: results.ok, checks: results.checks.length, embeddingRequests: results.embeddings.length,
|
|
416
|
+
retrieves: results.retrieves.length, failure: results.failure || null }))
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
async function parent() {
|
|
420
|
+
const launcher = path.join(process.env.APPDATA, 'in.dsh-plug.dsh-launcher')
|
|
421
|
+
const production = fs.realpathSync(options['production-home'] || path.join(launcher, 'homes/0.2.2-rc.5'))
|
|
422
|
+
const productionData = path.join(production, 'dsh-memu-memory')
|
|
423
|
+
const installation = fs.realpathSync(options.installation || path.join(launcher, 'versions/0.2.2-rc.5'))
|
|
424
|
+
const basePythonRoot = fs.realpathSync(options['base-python'] || path.join(os.homedir(), '.dsh/dsh-runtimes/dsh-primary-runtime/dependencies/python'))
|
|
425
|
+
const run = path.resolve(options.out || path.join(repo, 'logs', 'recovery-vector-' + new Date().toISOString().replace(/[:.]/g, '-')))
|
|
426
|
+
assert.ok(inside(path.join(repo, 'logs'), run) && path.basename(run).startsWith('recovery-vector-'))
|
|
427
|
+
assert.ok(!fs.existsSync(run), 'choose a new run directory')
|
|
428
|
+
const protectedPid = Number(options['protected-pid'])
|
|
429
|
+
assert.ok(Number.isSafeInteger(protectedPid) && protectedPid > 0, '--protected-pid required')
|
|
430
|
+
const productionIdentity = identity(protectedPid)
|
|
431
|
+
fs.mkdirSync(run, { recursive: true, mode: 0o700 })
|
|
432
|
+
const home = path.join(run, 'home'), data = path.join(home, 'dsh-memu-memory'), snapshot = path.join(run, 'plugin')
|
|
433
|
+
const clean = Object.fromEntries(Object.entries(process.env).filter(([key]) => !/(?:API[_-]?KEY|TOKEN|SECRET|CREDENTIAL|PASSWORD|^DSH_|^MEMU_|PROXY|^NODE_OPTIONS$|^NODE_PATH$|^PYTHON)/i.test(key)))
|
|
434
|
+
const write = (relative, value) => {
|
|
435
|
+
const file = path.resolve(run, relative)
|
|
436
|
+
assert.ok(inside(run, file), 'write escaped isolated directory')
|
|
437
|
+
fs.mkdirSync(path.dirname(file), { recursive: true })
|
|
438
|
+
fs.writeFileSync(file, Buffer.isBuffer(value) || typeof value === 'string' ? value : json(value), { mode: 0o600 })
|
|
439
|
+
}
|
|
440
|
+
const watched = new Map()
|
|
441
|
+
const productionRead = file => {
|
|
442
|
+
file = fs.realpathSync(file)
|
|
443
|
+
const root = [production, basePythonRoot].find(candidate => inside(candidate, file))
|
|
444
|
+
assert.ok(root, 'protected read outside named rc.5 home or base Python runtime')
|
|
445
|
+
const bytes = fs.readFileSync(file)
|
|
446
|
+
if (!watched.has(file)) watched.set(file, { file: `${root === production ? 'rc.5' : 'base-python'}/${path.relative(root, file).replaceAll('\\', '/')}`, bytes: bytes.length, sha256: hash(bytes) })
|
|
447
|
+
return bytes
|
|
448
|
+
}
|
|
449
|
+
const productionJson = relative => JSON.parse(productionRead(path.join(productionData, relative)))
|
|
450
|
+
const report = { schema: 1, ok: false, phase: options.phase || 'pre-freeze', run,
|
|
451
|
+
startedAt: new Date().toISOString(), protectedIdentity: productionIdentity, checks: [], productionWritesByHarness: 0,
|
|
452
|
+
constraints: { copiedStateOrHostProfile: false, installs: false, modelDownloads: false,
|
|
453
|
+
paidProvider: false, productionSqliteOpenedByHarness: false, originalTextInReports: false } }
|
|
454
|
+
const check = (name, ok, detail = {}) => { report.checks.push({ name, ok: Boolean(ok), ...detail }); assert.ok(ok, name) }
|
|
455
|
+
let childHandle
|
|
456
|
+
try {
|
|
457
|
+
const manifest = sourceManifest(repo)
|
|
458
|
+
for (const item of manifest) {
|
|
459
|
+
const file = item.file, bytes = fs.readFileSync(path.join(repo, file))
|
|
460
|
+
assert.equal(hash(bytes), item.sha256, `source changed while snapshotting: ${file}`)
|
|
461
|
+
write(path.join('plugin', file), bytes)
|
|
462
|
+
}
|
|
463
|
+
report.source = { snapshotSha256: hash(JSON.stringify(manifest)), files: manifest.length,
|
|
464
|
+
gitHead: execFileSync('git', ['rev-parse', 'HEAD'], { cwd: repo, encoding: 'utf8' }).trim(),
|
|
465
|
+
pluginVersion: read(path.join(snapshot, 'package.json')).version,
|
|
466
|
+
harnessSha256: hash(fs.readFileSync(fileURLToPath(import.meta.url))) }
|
|
467
|
+
write('source-manifest.json', manifest)
|
|
468
|
+
const state = productionJson('state.json'), vectors = productionJson('index/vector-active.json')
|
|
469
|
+
const runtime = productionJson('downloads/embeddings/runtime/active.json'), engine = productionJson('engine/current.json')
|
|
470
|
+
const active = vectors.active
|
|
471
|
+
check('production-active-vector-metadata', active?.generation > 0 && active?.profile?.catalogId && !vectors.pending)
|
|
472
|
+
const runtimeDir = fs.realpathSync(runtime.dir), modelDir = fs.realpathSync(path.join(productionData, 'downloads/embeddings', active.profile.catalogId))
|
|
473
|
+
const venv = fs.realpathSync(engine.venv)
|
|
474
|
+
const basePythonConfig = fs.readFileSync(path.join(venv, 'pyvenv.cfg'), 'utf8')
|
|
475
|
+
const basePythonSource = basePythonConfig.match(/^executable\s*=\s*(.+)$/m)?.[1]?.trim()
|
|
476
|
+
assert.ok(basePythonSource && inside(basePythonRoot, fs.realpathSync(basePythonSource)), 'MemU venv base Python must be inside the declared runtime')
|
|
477
|
+
check('runtime-model-and-python-sources-resolved', inside(production, runtimeDir) && inside(production, modelDir)
|
|
478
|
+
&& inside(production, fs.realpathSync(engine.python)) && inside(basePythonRoot, fs.realpathSync(basePythonSource)))
|
|
479
|
+
const isolated = path.join(run, 'artifacts')
|
|
480
|
+
const isolatedRuntime = path.join(isolated, 'runtime')
|
|
481
|
+
const isolatedModel = path.join(isolated, 'model')
|
|
482
|
+
const isolatedBasePythonRoot = path.join(isolated, 'base-python')
|
|
483
|
+
const isolatedVenv = path.join(isolated, 'memu-venv')
|
|
484
|
+
const copiedArtifacts = [
|
|
485
|
+
copyVerifiedTree(runtimeDir, isolatedRuntime, run),
|
|
486
|
+
copyVerifiedTree(modelDir, isolatedModel, run),
|
|
487
|
+
copyVerifiedTree(basePythonRoot, isolatedBasePythonRoot, run),
|
|
488
|
+
copyVerifiedTree(venv, isolatedVenv, run),
|
|
489
|
+
]
|
|
490
|
+
const isolatedBasePython = path.join(isolatedBasePythonRoot, path.relative(basePythonRoot, basePythonSource))
|
|
491
|
+
relocateVenvConfig(isolatedVenv, isolatedBasePython)
|
|
492
|
+
const isolatedPython = path.join(isolatedVenv, 'Scripts/python.exe')
|
|
493
|
+
const importResult = JSON.parse(execFileSync(isolatedPython, ['-c',
|
|
494
|
+
'import json, memu.cli; print(json.dumps({"ready": True, "module": memu.cli.__file__}))'], {
|
|
495
|
+
cwd: run, windowsHide: true, encoding: 'utf8',
|
|
496
|
+
env: { ...clean, USERPROFILE: path.join(run, 'user'), HOME: path.join(run, 'user'),
|
|
497
|
+
PYTHONNOUSERSITE: '1', PYTHONDONTWRITEBYTECODE: '1', HF_HUB_OFFLINE: '1', TRANSFORMERS_OFFLINE: '1' },
|
|
498
|
+
}))
|
|
499
|
+
check('isolated-memu-python-import', importResult.ready === true && inside(isolatedVenv, importResult.module))
|
|
500
|
+
report.isolatedArtifacts = copiedArtifacts.map(({ source, destination, ...item }) => ({
|
|
501
|
+
sourceRoot: source, isolatedRoot: path.relative(run, destination), ...item,
|
|
502
|
+
}))
|
|
503
|
+
const profileKeys = ['schema', 'catalogId', 'manifest', 'modelDir', 'runtimeDir', 'fingerprint', 'short', 'displayName', 'manifestDigest',
|
|
504
|
+
'provider', 'repo', 'revision', 'dimension', 'maxTokens', 'pooling', 'normalization', 'prefixes', 'quantization', 'runtime', 'files',
|
|
505
|
+
'graphSha256', 'tokenizerSha256', 'verification']
|
|
506
|
+
const profile = Object.fromEntries(profileKeys.filter(key => active.profile[key] !== undefined).map(key => [key, active.profile[key]]))
|
|
507
|
+
profile.modelDir = isolatedModel; profile.runtimeDir = isolatedRuntime
|
|
508
|
+
const artifactInventory = []
|
|
509
|
+
const protectedArtifactFiles = new Set()
|
|
510
|
+
for (const [kind, root] of [['runtime', runtimeDir], ['model', modelDir], ['base-python', basePythonRoot], ['memu-venv', venv]]) {
|
|
511
|
+
for (const item of inventory(root)) {
|
|
512
|
+
const file = fs.realpathSync(path.join(root, item.file))
|
|
513
|
+
protectedArtifactFiles.add(file)
|
|
514
|
+
assert.equal(hash(productionRead(file)), item.sha256, `protected artifact changed during inventory: ${item.file}`)
|
|
515
|
+
artifactInventory.push({ kind, ...item })
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
report.runtime = { engine: runtime.engine, version: runtime.version, abi: runtime.abi,
|
|
519
|
+
inventorySha256: hash(JSON.stringify(artifactInventory.filter(item => item.kind === 'runtime'))) }
|
|
520
|
+
report.model = { catalogId: profile.catalogId, dimension: profile.dimension, fingerprint: profile.fingerprint,
|
|
521
|
+
manifestDigest: profile.manifestDigest, recordedPathsRebasedInIsolation: active.profile.modelDir !== modelDir || active.profile.runtimeDir !== runtimeDir,
|
|
522
|
+
inventorySha256: hash(JSON.stringify(artifactInventory.filter(item => item.kind === 'model'))) }
|
|
523
|
+
report.engine = { version: engine.version, pythonSha256: hash(productionRead(engine.python)),
|
|
524
|
+
basePythonInventorySha256: hash(JSON.stringify(artifactInventory.filter(item => item.kind === 'base-python'))),
|
|
525
|
+
venvInventorySha256: hash(JSON.stringify(artifactInventory.filter(item => item.kind === 'memu-venv'))) }
|
|
526
|
+
write('artifact-manifest.json', artifactInventory)
|
|
527
|
+
const eligible = entry => entry?.title && entry.content && (!entry.status || entry.status === 'active') && !entry.marginalized &&
|
|
528
|
+
entry.visibility === 'shared' && entry.disclosure === 'can_tell' && !Object.keys(entry.context || {}).length &&
|
|
529
|
+
(!entry.expiresAt || Date.parse(entry.expiresAt) > Date.now())
|
|
530
|
+
const candidates = []
|
|
531
|
+
for (const [libraryId, db] of Object.entries(active.databases.libraries || {})) {
|
|
532
|
+
if (!/^lib_[a-z0-9]+$/i.test(libraryId) || !state.libraries?.[libraryId] || state.libraries[libraryId].archived) continue
|
|
533
|
+
const file = path.join(productionData, 'index', libraryId + '.json')
|
|
534
|
+
const raw = productionRead(file), index = JSON.parse(raw)
|
|
535
|
+
for (const domain of ['rp', 'coding']) {
|
|
536
|
+
const ids = Object.entries(index.entries || {}).filter(([, entry]) => eligible(entry) && entry.domain === domain).map(([id]) => id)
|
|
537
|
+
if (ids.length) candidates.push({ libraryId, db, raw, domain, candidateIds: ids })
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
const bySize = (a, b) => a.raw.length - b.raw.length
|
|
541
|
+
const primaryDomain = ['rp', 'coding'].find(domain => candidates.filter(item => item.domain === domain).length >= 2)
|
|
542
|
+
const sameDomain = candidates.filter(item => item.domain === primaryDomain).sort(bySize).slice(0, 2)
|
|
543
|
+
const foreign = candidates.filter(item => item.domain !== primaryDomain && !sameDomain.some(other => other.libraryId === item.libraryId)).sort(bySize)[0]
|
|
544
|
+
check('three-eligible-real-library-fixtures', sameDomain.length === 2 && Boolean(foreign))
|
|
545
|
+
const selected = [...sameDomain, foreign]
|
|
546
|
+
const safeState = { version: 1, settings: { memoryBackend: 'api', vectorSource: 'local', memoryMode: 'local', autoInstallEngine: false,
|
|
547
|
+
sleepConsolidation: false, autoCurateEveryHours: 0, autoRepairEntityFragments: false, salientWake: 'off', retentionDryRun: true,
|
|
548
|
+
crossLibraryRecall: false, relevanceThreshold: 0, randomCueChance: 0, habitsInjection: false, consolidationTurnLog: 'off',
|
|
549
|
+
visionCaptionEnabled: false, autoLinkMode: 'off' }, libraries: {}, sessions: {}, workspacePolicies: {}, cycle: { entityRepairVersion: 1 } }
|
|
550
|
+
const databases = { global: { ...active.databases.global }, libraries: {} }, config = {
|
|
551
|
+
hostAnchor: path.join(installation, 'node_modules/@deepseek-ai/dsh/package.json'), fingerprint: profile.fingerprint,
|
|
552
|
+
catalogId: profile.catalogId, dimension: profile.dimension, fixtures: [], databases: { global: active.databases.global.path } }
|
|
553
|
+
const copies = []
|
|
554
|
+
const copyDb = entry => {
|
|
555
|
+
assert.ok(/^libraries\/[a-zA-Z0-9_.-]+\.sqlite3$/.test(entry.path), 'unsafe active database path')
|
|
556
|
+
const source = path.join(productionData, entry.path)
|
|
557
|
+
assert.ok(!['-wal', '-shm', '-journal'].some(suffix => fs.existsSync(source + suffix)), 'active SQLite sidecar: cannot safely byte-copy')
|
|
558
|
+
const bytes = productionRead(source)
|
|
559
|
+
write(path.join('home/dsh-memu-memory', entry.path), bytes)
|
|
560
|
+
assert.equal(hash(productionRead(source)), hash(bytes), 'production DB changed during copy; rerun in a new output directory')
|
|
561
|
+
assert.ok(!['-wal', '-shm', '-journal'].some(suffix => fs.existsSync(source + suffix)), 'SQLite sidecar appeared during copy')
|
|
562
|
+
const db = new DatabaseSync(path.join(data, entry.path), { readOnly: true })
|
|
563
|
+
let rows
|
|
564
|
+
try {
|
|
565
|
+
assert.equal(db.prepare('PRAGMA quick_check').get().quick_check, 'ok')
|
|
566
|
+
rows = db.prepare('SELECT name FROM memu_recall_files WHERE embedding IS NOT NULL').all().map(row => row.name.replace(/\.md$/i, ''))
|
|
567
|
+
copies.push({ path: entry.path, bytes: bytes.length, sha256: hash(bytes), embeddedFiles: rows.length,
|
|
568
|
+
segments: db.prepare('SELECT count(*) AS n FROM memu_recall_file_segments WHERE embedding IS NOT NULL').get().n })
|
|
569
|
+
} finally { db.close() }
|
|
570
|
+
return new Set(rows)
|
|
571
|
+
}
|
|
572
|
+
copyDb(databases.global)
|
|
573
|
+
for (const [i, fixture] of selected.entries()) {
|
|
574
|
+
const vectorIds = copyDb(fixture.db)
|
|
575
|
+
const ids = fixture.candidateIds.filter(id => vectorIds.has(id))
|
|
576
|
+
check('real-id-intersection:' + fixture.libraryId, ids.length > 0, { matchingIds: ids.length })
|
|
577
|
+
write('home/dsh-memu-memory/index/' + fixture.libraryId + '.json', fixture.raw)
|
|
578
|
+
const scopeKey = path.join(run, 'workspace', String(i)).replaceAll('\\', '/').toLowerCase()
|
|
579
|
+
const sessionId = 'recovery-vector-' + i
|
|
580
|
+
safeState.libraries[fixture.libraryId] = { name: 'Isolated vector fixture ' + i, scopeKey, archived: false,
|
|
581
|
+
createdAt: new Date().toISOString(), lastUsedAt: new Date().toISOString() }
|
|
582
|
+
safeState.sessions[sessionId] = { useLibrary: true, useGlobal: false, libraryId: fixture.libraryId, scopeKey,
|
|
583
|
+
domain: fixture.domain, domainOverride: fixture.domain, memoryContext: {}, injectedIds: [], injectedAt: {}, lastInjectedTurn: 0 }
|
|
584
|
+
safeState.workspacePolicies[scopeKey] = { useLibrary: true, useGlobal: false }
|
|
585
|
+
databases.libraries[fixture.libraryId] = { ...fixture.db }
|
|
586
|
+
config.databases[fixture.libraryId] = fixture.db.path
|
|
587
|
+
config.fixtures.push({ libraryId: fixture.libraryId, domain: fixture.domain, sessionId, candidateIds: ids })
|
|
588
|
+
}
|
|
589
|
+
write('copied-databases.json', copies)
|
|
590
|
+
// Only the vector-space manifest is projected; no production host profile/state is copied.
|
|
591
|
+
write('home/dsh-memu-memory/index/vector-active.json', { version: 1, generation: vectors.generation, requested: null, pending: null,
|
|
592
|
+
active: { status: 'active', generation: active.generation, fingerprint: active.fingerprint, profile, databases } })
|
|
593
|
+
write('home/dsh-memu-memory/index/global.json', productionRead(path.join(productionData, 'index/global.json')))
|
|
594
|
+
write('home/dsh-memu-memory/state.json', safeState)
|
|
595
|
+
write('home/dsh-memu-memory/engine/current.json', { version: engine.version, python: isolatedPython, venv: isolatedVenv })
|
|
596
|
+
write('fixture-config.json', config)
|
|
597
|
+
for (const relative of ['.credentials.yaml', 'profiles/web/package.json', 'profiles/web/cordis.patch.yml']) {
|
|
598
|
+
const file = path.join(production, relative)
|
|
599
|
+
if (fs.existsSync(file)) productionRead(file)
|
|
600
|
+
}
|
|
601
|
+
write('production-before.json', [...watched.values()])
|
|
602
|
+
const user = path.join(run, 'user')
|
|
603
|
+
for (const dir of [user, path.join(user, 'roaming'), path.join(user, 'local'), path.join(run, 'tmp')]) fs.mkdirSync(dir, { recursive: true })
|
|
604
|
+
const env = { ...clean, DSH_HOME: home, DSH_MEMU_HOME: data, DSH_MEMU_MEMORY_HOME: data,
|
|
605
|
+
USERPROFILE: user, HOME: user, APPDATA: path.join(user, 'roaming'), LOCALAPPDATA: path.join(user, 'local'),
|
|
606
|
+
TMP: path.join(run, 'tmp'), TEMP: path.join(run, 'tmp'), HF_HOME: path.join(user, 'huggingface'),
|
|
607
|
+
XDG_CACHE_HOME: path.join(user, 'cache'), XDG_CONFIG_HOME: path.join(user, 'config'),
|
|
608
|
+
HF_HUB_OFFLINE: '1', TRANSFORMERS_OFFLINE: '1', PYTHONDONTWRITEBYTECODE: '1', PYTHONNOUSERSITE: '1',
|
|
609
|
+
MEMU_TELEMETRY: '0', DO_NOT_TRACK: '1', MEMU_EVENTS_BASE_URL: '', NO_PROXY: '127.0.0.1,localhost',
|
|
610
|
+
DSH_MEMU_RT_INDEX: 'off' }
|
|
611
|
+
const stdout = fs.openSync(path.join(run, 'qa.stdout.log'), 'wx', 0o600), stderr = fs.openSync(path.join(run, 'qa.stderr.log'), 'wx', 0o600)
|
|
612
|
+
let timer, childCleanup = null
|
|
613
|
+
try {
|
|
614
|
+
childHandle = spawn(process.execPath, ['--disable-warning=ExperimentalWarning', fileURLToPath(import.meta.url), '--child=' + run],
|
|
615
|
+
{ env, cwd: run, windowsHide: true, stdio: ['ignore', stdout, stderr] })
|
|
616
|
+
report.childPid = childHandle.pid
|
|
617
|
+
timer = setTimeout(() => {
|
|
618
|
+
report.childTimeout = true
|
|
619
|
+
childCleanup = terminateOwnedTree(childHandle, protectedPid)
|
|
620
|
+
}, 12 * 60000)
|
|
621
|
+
report.childExit = await new Promise((resolve, reject) => { childHandle.once('error', reject); childHandle.once('close', resolve) })
|
|
622
|
+
} finally {
|
|
623
|
+
clearTimeout(timer)
|
|
624
|
+
if (childHandle && childHandle.exitCode === null && childHandle.signalCode === null && !childCleanup) {
|
|
625
|
+
childCleanup = terminateOwnedTree(childHandle, protectedPid)
|
|
626
|
+
}
|
|
627
|
+
try {
|
|
628
|
+
if (childCleanup) report.childCleanup = await childCleanup
|
|
629
|
+
} finally { fs.closeSync(stdout); fs.closeSync(stderr) }
|
|
630
|
+
}
|
|
631
|
+
const qa = read(path.join(run, 'vector-results.json'))
|
|
632
|
+
report.qa = { ok: qa.ok, checks: qa.checks.length, failed: qa.checks.filter(item => !item.ok),
|
|
633
|
+
embeddings: qa.embeddings.length, retrieves: qa.retrieves.length, recalls: qa.recalls.length,
|
|
634
|
+
failure: qa.failure || null }
|
|
635
|
+
check('real-vector-qa-completed', report.childExit === 0 && qa.ok)
|
|
636
|
+
} catch (error) {
|
|
637
|
+
report.failure = { code: error.code || error.name, messageSha256: hash(String(error.message)),
|
|
638
|
+
assertion: report.checks.findLast(item => !item.ok)?.name || null }
|
|
639
|
+
process.exitCode = 1
|
|
640
|
+
} finally {
|
|
641
|
+
const auditErrors = []
|
|
642
|
+
const audit = async (stage, action) => {
|
|
643
|
+
try { await action() } catch (error) {
|
|
644
|
+
auditErrors.push({ stage, code: error.code || error.name || 'ERROR', messageSha256: hash(String(error.message || error)) })
|
|
645
|
+
process.exitCode = 1
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
const auditCheck = (name, ok, detail = {}) => report.checks.push({ name, ok: Boolean(ok), ...detail })
|
|
649
|
+
await audit('owned-child-cleanup', async () => {
|
|
650
|
+
if (!childHandle || childHandle.exitCode !== null || childHandle.signalCode !== null) return
|
|
651
|
+
report.childCleanup = await terminateOwnedTree(childHandle, protectedPid)
|
|
652
|
+
if (!report.childCleanup.closed) throw new Error('isolated child process tree did not close')
|
|
653
|
+
})
|
|
654
|
+
auditCheck('isolated-child-process-tree-closed', !childHandle || childHandle.exitCode !== null || childHandle.signalCode !== null,
|
|
655
|
+
{ pid: childHandle?.pid ?? null, cleanup: report.childCleanup || null })
|
|
656
|
+
audit('production-file-audit', () => {
|
|
657
|
+
const changes = []
|
|
658
|
+
for (const [file, before] of watched) {
|
|
659
|
+
try {
|
|
660
|
+
const bytes = fs.readFileSync(file)
|
|
661
|
+
const after = { ...before, bytes: bytes.length, sha256: hash(bytes) }
|
|
662
|
+
if (after.sha256 !== before.sha256) changes.push({ before, after })
|
|
663
|
+
} catch (error) { changes.push({ before, after: { file: before.file, errorCode: error.code || error.name || 'ERROR' } }) }
|
|
664
|
+
}
|
|
665
|
+
report.production = { monitoredFiles: watched.size, changedFiles: changes, harnessWrites: 0,
|
|
666
|
+
liveChangesAttribution: 'Production remains live. Any changed hash is reported, never attributed to this harness without evidence.' }
|
|
667
|
+
audit('production-process-identity', () => {
|
|
668
|
+
report.protectedIdentityAfter = identity(protectedPid)
|
|
669
|
+
report.production.identityPreserved = JSON.stringify(report.protectedIdentityAfter) === JSON.stringify(productionIdentity)
|
|
670
|
+
})
|
|
671
|
+
if (report.production.identityPreserved === undefined) report.production.identityPreserved = false
|
|
672
|
+
auditCheck('production-process-identity-preserved', report.production.identityPreserved)
|
|
673
|
+
const changedProtectedArtifacts = changes.filter(item => protectedArtifactFiles.has(item.before.file === undefined
|
|
674
|
+
? '' : [...watched.entries()].find(([file, before]) => before === item.before)?.[0]))
|
|
675
|
+
report.production.changedProtectedArtifacts = changedProtectedArtifacts.map(item => item.before.file)
|
|
676
|
+
auditCheck('runtime-model-python-venv-files-unchanged', changedProtectedArtifacts.length === 0,
|
|
677
|
+
{ count: changedProtectedArtifacts.length })
|
|
678
|
+
})
|
|
679
|
+
audit('source-manifest-audit', () => {
|
|
680
|
+
const manifest = read(path.join(run, 'source-manifest.json'))
|
|
681
|
+
const comparison = compareSourceManifests(manifest, sourceManifest(repo))
|
|
682
|
+
report.source.currentTreeMatches = comparison.matches
|
|
683
|
+
report.source.changedFilesDuringRun = comparison.changed
|
|
684
|
+
report.source.addedFilesDuringRun = comparison.added
|
|
685
|
+
report.source.removedFilesDuringRun = comparison.removed
|
|
686
|
+
if (report.phase === 'frozen-final') auditCheck('frozen-source-stable', comparison.matches, comparison)
|
|
687
|
+
})
|
|
688
|
+
report.auditErrors = auditErrors
|
|
689
|
+
report.finishedAt = new Date().toISOString()
|
|
690
|
+
report.ok = !report.failure && auditErrors.length === 0 && report.checks.every(item => item.ok)
|
|
691
|
+
if (!report.ok) process.exitCode = 1
|
|
692
|
+
try { write('report.json', report) } catch (error) {
|
|
693
|
+
auditErrors.push({ stage: 'final-report-write', code: error.code || error.name || 'ERROR', messageSha256: hash(String(error.message || error)) })
|
|
694
|
+
report.ok = false
|
|
695
|
+
process.exitCode = 1
|
|
696
|
+
try { write('report.partial.json', report) } catch (fallbackError) {
|
|
697
|
+
process.stderr.write(`Unable to persist vector QA report (${fallbackError.code || fallbackError.name || 'ERROR'}).\n`)
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
console.log(JSON.stringify({ ok: report.ok, sourceSha256: report.source?.snapshotSha256 ?? null,
|
|
702
|
+
qa: report.qa, protectedIdentityPreserved: report.production?.identityPreserved ?? false,
|
|
703
|
+
productionChangedFiles: report.production?.changedFiles?.length ?? null, run }))
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
async function selfTest() {
|
|
707
|
+
const temp = fs.mkdtempSync(path.join(process.env.TEMP || process.env.TMP || '.', 'verify-vector-self-test-'))
|
|
708
|
+
try {
|
|
709
|
+
const sourceRoot = path.join(temp, 'repo')
|
|
710
|
+
fs.mkdirSync(path.join(sourceRoot, 'lib'), { recursive: true })
|
|
711
|
+
fs.mkdirSync(path.join(sourceRoot, 'assets'), { recursive: true })
|
|
712
|
+
fs.writeFileSync(path.join(sourceRoot, 'lib/a.js'), 'a')
|
|
713
|
+
fs.writeFileSync(path.join(sourceRoot, 'assets/a.png'), 'b')
|
|
714
|
+
fs.writeFileSync(path.join(sourceRoot, 'package.json'), '{}')
|
|
715
|
+
fs.writeFileSync(path.join(sourceRoot, 'cordis.patch.yml'), 'patch')
|
|
716
|
+
const before = sourceManifest(sourceRoot)
|
|
717
|
+
fs.writeFileSync(path.join(sourceRoot, 'lib/new.js'), 'c')
|
|
718
|
+
assert.deepEqual(compareSourceManifests(before, sourceManifest(sourceRoot)),
|
|
719
|
+
{ matches: false, added: ['lib/new.js'], removed: [], changed: [] })
|
|
720
|
+
fs.writeFileSync(path.join(sourceRoot, 'assets/a.png'), 'changed')
|
|
721
|
+
fs.rmSync(path.join(sourceRoot, 'lib/a.js'))
|
|
722
|
+
assert.deepEqual(compareSourceManifests(before, sourceManifest(sourceRoot)),
|
|
723
|
+
{ matches: false, added: ['lib/new.js'], removed: ['lib/a.js'], changed: ['assets/a.png'] })
|
|
724
|
+
const data = path.join(temp, 'home/dsh-memu-memory')
|
|
725
|
+
const generation = { global: path.join(data, 'libraries/global.sqlite3'), libraries: { lib_a: path.join(data, 'libraries/lib_a.sqlite3') } }
|
|
726
|
+
assertGenerationDatabasesIsolated(data, generation, { global: 'libraries/global.sqlite3', libraries: { lib_a: 'libraries/lib_a.sqlite3' } })
|
|
727
|
+
assert.throws(() => assertGenerationDatabasesIsolated(data, { ...generation, global: path.join(temp, 'production.sqlite3') },
|
|
728
|
+
{ global: 'libraries/global.sqlite3', libraries: { lib_a: 'libraries/lib_a.sqlite3' } }))
|
|
729
|
+
assert.equal(managerIsStopped({ closed: true, running: 0, booting: 0 }), true)
|
|
730
|
+
assert.equal(managerIsStopped({ closed: true, running: 1, booting: 0 }), false)
|
|
731
|
+
assert.equal(managerIsStopped({ closed: false, running: 0, booting: 0 }), false)
|
|
732
|
+
process.stdout.write('verify-vector-recovery self-test: 7 assertions passed\n')
|
|
733
|
+
} finally {
|
|
734
|
+
fs.rmSync(temp, { recursive: true, force: true })
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
if (options['self-test']) await selfTest()
|
|
739
|
+
else if (options.child) await child(options.child)
|
|
740
|
+
else await parent()
|