forked from cflmy/deepseek-harness
Implement the downstream product in `packages/marqdo`: - `@marqdo/mdh-harness`: application home layout, atomic writes, locks, bounded fixed-argv processes, safe tar extraction, Observation 1 and ValueWire validation; - trusted Gitea release discovery, SHA-256/platform/Bundle verification, transactional environment install, rollback and cleanup, CLI Tool changes; - private knowledge collections with strict import policy, the official `marqdo-knowledge` compile/query adapter and a disclosed locator fallback; - Analysis 3 parsing, approved run/call execution, evidence and staleness; - the six model operations (find/read/check/program/ecosystem/knowledge_search); - the `/mdh` workbench over the existing web server with a same-origin fence; - `mdh` launcher, CI/package/upstream scripts and a Woodpecker pipeline. Tests: 28 node:test cases (27 PASS, one network-gated install test also PASS with MDH_TEST_INSTALL=1). Product install/workbench evidence is recorded in docs/mdh/evidence. Part of marqdo#25 (MDH-03..MDH-08).
54 lines
2.4 KiB
TypeScript
54 lines
2.4 KiB
TypeScript
/**
|
|
* Real trusted-release installation. Network access is explicit:
|
|
* `MDH_TEST_INSTALL=1` selects this test and CI provides it. It installs the
|
|
* public rc.5 and rc.6 CLI releases, verifies the active pointer, the adjacent
|
|
* Bundle identity, and rollback. Evidence is printed for the release record.
|
|
*/
|
|
|
|
import assert from 'node:assert/strict'
|
|
import { mkdtemp, readFile } from 'node:fs/promises'
|
|
import { tmpdir } from 'node:os'
|
|
import { join } from 'node:path'
|
|
import { test } from 'node:test'
|
|
|
|
import { ensureMdhHome } from '../src/core/home.ts'
|
|
import { EcosystemManager } from '../src/ecosystem/manager.ts'
|
|
|
|
const enabled = process.env.MDH_TEST_INSTALL === '1'
|
|
|
|
test('installs two real releases and rolls back', { skip: enabled ? false : 'MDH_TEST_INSTALL is not 1' }, async () => {
|
|
const root = await mkdtemp(join(tmpdir(), 'mdh-install-'))
|
|
const layout = await ensureMdhHome(join(root, 'home'))
|
|
const manager = new EcosystemManager(layout)
|
|
|
|
const first = await manager.install({ version: '3.0.0-rc.5' })
|
|
assert.equal(first.environment.version, '3.0.0-rc.5')
|
|
assert.match(first.environment.source_sha ?? '', /^[0-9a-f]{40}$/)
|
|
assert.match(first.environment.bundle.tree_digest, /^sha256:[0-9a-f]{64}$/)
|
|
const firstCli = await manager.cliPath()
|
|
assert.ok(firstCli)
|
|
assert.match((await readFile(join(layout.environments, first.environment.id, 'SOURCE_SHA'), 'utf8')).trim(), /^[0-9a-f]{40}$/)
|
|
|
|
const second = await manager.install({ version: '3.0.0-rc.6' })
|
|
assert.equal(second.environment.version, '3.0.0-rc.6')
|
|
assert.equal(second.environment.previous, first.environment.id)
|
|
|
|
const status = await manager.status()
|
|
assert.equal(status.runtime.version, '3.0.0-rc.6')
|
|
assert.equal(status.std.modules.length > 0, true)
|
|
assert.equal(status.environments.length, 2)
|
|
|
|
const rolled = await manager.rollback()
|
|
assert.equal(rolled.active.id, first.environment.id)
|
|
assert.equal((await manager.status()).runtime.version, '3.0.0-rc.5')
|
|
|
|
// A bad version resolves to no candidate and must not disturb the pointer.
|
|
await assert.rejects(manager.install({ version: '9.9.9' }), /no trusted release/)
|
|
assert.equal((await manager.status()).runtime.version, '3.0.0-rc.5')
|
|
|
|
const cleaned = await manager.cleanup()
|
|
// Both the active and the rollback target stay protected.
|
|
assert.equal(cleaned.kept.includes(first.environment.id), true)
|
|
assert.equal(cleaned.kept.includes(second.environment.id), true)
|
|
})
|