feat(reporting-governance): add profile artifact binding slice
This commit is contained in:
47
plugins/reporting-governance/test/profile-artifact.test.mjs
Normal file
47
plugins/reporting-governance/test/profile-artifact.test.mjs
Normal file
@@ -0,0 +1,47 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
import { loadDeploymentProfileArtifact, createDeploymentBindingContract } from '../src/storage/profile-artifact.mjs';
|
||||
import { createRuntimeBinding } from '../src/adapters/index.mjs';
|
||||
|
||||
const packageRoot = path.resolve(import.meta.dirname, '..');
|
||||
const repoRoot = path.resolve(packageRoot, '..', '..');
|
||||
|
||||
test('deployment profile artifact loads from package profiles and preserves compatibility envelope metadata', () => {
|
||||
const { artifactPath, artifact } = loadDeploymentProfileArtifact({ profileId: 'strict-manager-mode' });
|
||||
|
||||
assert.equal(path.relative(packageRoot, artifactPath), path.join('profiles', 'strict-manager-mode.profile.json'));
|
||||
assert.equal(artifact.kind, 'DeploymentProfileArtifact');
|
||||
assert.equal(artifact.metadata.id, 'strict-manager-mode');
|
||||
assert.equal(artifact.metadata.compatibility_mode, 'strict_envelope');
|
||||
assert.equal(artifact.spec.package.pluginVersion, '0.1.0-mainline');
|
||||
});
|
||||
|
||||
test('deployment binding contract resolves package artifact into real repo script and artifact paths', () => {
|
||||
const { artifact } = loadDeploymentProfileArtifact({ profileId: 'strict-manager-mode' });
|
||||
const binding = createDeploymentBindingContract({ artifact });
|
||||
|
||||
assert.equal(binding.runtime, 'openclaw');
|
||||
assert.equal(binding.pluginVersion, '0.1.0-mainline');
|
||||
assert.equal(binding.compatibilityMode, 'strict_envelope');
|
||||
assert.equal(binding.entrypoint, path.resolve(repoRoot, 'scripts/watchdog_auto_notify_orchestrator.mjs'));
|
||||
assert.equal(binding.scripts.watchdog, path.resolve(repoRoot, 'scripts/long_task_watchdog.mjs'));
|
||||
assert.equal(binding.artifactRoots.queueItems, path.resolve(repoRoot, 'state/operator-notify-queue'));
|
||||
assert.equal(fs.existsSync(binding.scripts.orchestrator), true);
|
||||
});
|
||||
|
||||
test('runtime binding can be instantiated from profile artifact binding contract', () => {
|
||||
const { artifact } = loadDeploymentProfileArtifact({ profileId: 'strict-manager-mode' });
|
||||
const contract = createDeploymentBindingContract({ artifact });
|
||||
const runtimeBinding = createRuntimeBinding({
|
||||
cwd: repoRoot,
|
||||
scripts: contract.scripts,
|
||||
});
|
||||
|
||||
assert.equal(runtimeBinding.cwd, repoRoot);
|
||||
assert.equal(runtimeBinding.scripts.dispatcher, contract.scripts.dispatcher);
|
||||
assert.equal(runtimeBinding.scripts.bridgeSupervisor, contract.scripts.bridgeSupervisor);
|
||||
assert.equal(runtimeBinding.scripts.senderBinding, contract.scripts.senderBinding);
|
||||
});
|
||||
Reference in New Issue
Block a user