feat(reporting-governance): add package-first portability smoke
This commit is contained in:
103
plugins/reporting-governance/scripts/package-smoke.mjs
Normal file
103
plugins/reporting-governance/scripts/package-smoke.mjs
Normal file
@@ -0,0 +1,103 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import process from 'node:process';
|
||||
|
||||
import { generateDeploymentProfileArtifactFromFile } from '../src/storage/profile-generator.mjs';
|
||||
import { runOrchestratorAdapter } from '../src/adapters/orchestrator.mjs';
|
||||
|
||||
const packageRoot = path.resolve(import.meta.dirname, '..');
|
||||
|
||||
function parseArgs(argv) {
|
||||
const args = {
|
||||
workspace: null,
|
||||
now: '2026-05-07T08:20:00.000Z',
|
||||
compact: false,
|
||||
};
|
||||
|
||||
for (let i = 0; i < argv.length; i += 1) {
|
||||
const token = argv[i];
|
||||
if (token === '--compact') { args.compact = true; continue; }
|
||||
if (token === '--workspace') { args.workspace = argv[i + 1] ?? null; i += 1; continue; }
|
||||
if (token.startsWith('--workspace=')) { args.workspace = token.slice('--workspace='.length) || null; continue; }
|
||||
if (token === '--now') { args.now = argv[i + 1] ?? args.now; i += 1; continue; }
|
||||
if (token.startsWith('--now=')) { args.now = token.slice('--now='.length) || args.now; continue; }
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
function mkdirs(root, names) {
|
||||
for (const name of names) {
|
||||
fs.mkdirSync(path.join(root, name), { recursive: true });
|
||||
}
|
||||
}
|
||||
|
||||
function writeState(root) {
|
||||
const statePath = path.join(root, 'watchdog-state.json');
|
||||
fs.writeFileSync(statePath, `${JSON.stringify({
|
||||
version: 1,
|
||||
watchdogs: [
|
||||
{
|
||||
id: 'reporting-governance-plugin-watchdog',
|
||||
task: 'reporting-governance plugin package smoke',
|
||||
status: 'active',
|
||||
ownerSessionKey: 'agent:coder:main',
|
||||
reportChannel: 'telegram',
|
||||
reportTarget: '864811879',
|
||||
intervalMinutes: 10,
|
||||
lastMilestoneAt: '2026-05-07T08:00:00.000Z',
|
||||
lastAlertAt: null,
|
||||
}
|
||||
]
|
||||
}, null, 2)}\n`, 'utf8');
|
||||
return statePath;
|
||||
}
|
||||
|
||||
function main() {
|
||||
const args = parseArgs(process.argv.slice(2));
|
||||
const workspace = path.resolve(args.workspace ?? fs.mkdtempSync(path.join(os.tmpdir(), 'reporting-governance-package-smoke-')));
|
||||
mkdirs(workspace, ['evidence', 'events', 'queue', 'spool', 'receipts']);
|
||||
const state = writeState(workspace);
|
||||
|
||||
const profileSourcePath = path.join(packageRoot, 'profiles-src', 'strict-manager-mode.yaml');
|
||||
const artifact = generateDeploymentProfileArtifactFromFile(profileSourcePath);
|
||||
const artifactPath = path.join(workspace, 'strict-manager-mode.profile.json');
|
||||
fs.writeFileSync(artifactPath, `${JSON.stringify(artifact, null, 2)}\n`, 'utf8');
|
||||
|
||||
const result = runOrchestratorAdapter({
|
||||
profileArtifact: artifact,
|
||||
repoRootOverride: packageRoot,
|
||||
state,
|
||||
evidenceDir: path.join(workspace, 'evidence'),
|
||||
eventDir: path.join(workspace, 'events'),
|
||||
queueDir: path.join(workspace, 'queue'),
|
||||
spoolDir: path.join(workspace, 'spool'),
|
||||
receiptDir: path.join(workspace, 'receipts'),
|
||||
writeState: true,
|
||||
dryRun: true,
|
||||
now: args.now,
|
||||
});
|
||||
|
||||
const payload = {
|
||||
ok: true,
|
||||
tool: 'reporting-governance-package-smoke',
|
||||
packageRoot,
|
||||
workspace,
|
||||
artifactPath,
|
||||
generatedProfileSource: profileSourcePath,
|
||||
orchestrator: {
|
||||
ok: result?.ok === true,
|
||||
dispatchedCount: result?.result?.dispatcher?.dispatchedCount ?? null,
|
||||
pendingCount: result?.result?.supervisor?.pendingCount ?? null,
|
||||
notificationCount: result?.result?.watchdog?.notificationCount ?? null,
|
||||
executionOrder: result?.executionOrder ?? null,
|
||||
},
|
||||
};
|
||||
|
||||
process.stdout.write(`${JSON.stringify(payload, null, args.compact ? 0 : 2)}\n`);
|
||||
}
|
||||
|
||||
main();
|
||||
Reference in New Issue
Block a user