@volter/supercode-orchestrator 0.4.133 → 0.4.135
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/board/ci.mjs +50 -6
- package/package.json +1 -1
package/board/ci.mjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// Deployment evidence is observed before a board mutation. No network or Git
|
|
2
2
|
// process runs inside the optimistic transaction that decides completion.
|
|
3
3
|
import { spawnSync } from 'node:child_process';
|
|
4
|
-
import { readFileSync, realpathSync, writeFileSync, renameSync } from 'node:fs';
|
|
4
|
+
import { readFileSync, realpathSync, writeFileSync, renameSync, lstatSync } from 'node:fs';
|
|
5
5
|
import { dirname, join, relative } from 'node:path';
|
|
6
|
+
import { homedir } from 'node:os';
|
|
7
|
+
import { pathToFileURL } from 'node:url';
|
|
6
8
|
import { createHash } from 'node:crypto';
|
|
7
9
|
|
|
8
10
|
const observations = new Map();
|
|
@@ -43,6 +45,27 @@ export function observeCompletionEvidence(board, id, entry, payload = {}) {
|
|
|
43
45
|
const repo = /(?:github\.com[:/])([^/]+\/[^/]+?)(?:\.git)?$/.exec(remote)?.[1];
|
|
44
46
|
if (!repo) throw new Error('Deployment evidence requires this workspace\'s GitHub origin.');
|
|
45
47
|
Object.assign(state, { commit, repository: repo });
|
|
48
|
+
const controller = entry.params.completion_ci.controller_deployments?.[repo];
|
|
49
|
+
if (controller) {
|
|
50
|
+
const expand = value => value.startsWith('~/') ? join(homedir(), value.slice(2)) : value;
|
|
51
|
+
const installed = expand(controller.installed_path);
|
|
52
|
+
if (!lstatSync(installed).isSymbolicLink()) throw new Error('The controller installation must be the declared checkout symlink.');
|
|
53
|
+
const skill = realpathSync(installed), checkout = run('git', ['rev-parse', '--show-toplevel'], skill);
|
|
54
|
+
const origin = /(?:github\.com[:/])([^/]+\/[^/]+?)(?:\.git)?$/.exec(run('git', ['remote', 'get-url', 'origin'], checkout))?.[1];
|
|
55
|
+
if (origin !== repo) throw new Error('The controller installation points to another repository.');
|
|
56
|
+
const head = run('git', ['rev-parse', 'HEAD'], checkout);
|
|
57
|
+
run('git', ['merge-base', '--is-ancestor', commit, head], checkout);
|
|
58
|
+
run('git', ['diff', '--quiet', 'HEAD', '--', relative(checkout, join(skill, 'scripts'))], checkout);
|
|
59
|
+
const sourceHash = run(process.execPath, ['--experimental-strip-types', '--input-type=module', '-e',
|
|
60
|
+
'const m=await import(process.argv[1]); process.stdout.write(m.installedSourceHash())', pathToFileURL(join(skill, 'scripts/controller-diagnostics.ts')).href], checkout);
|
|
61
|
+
const port = Number(readFileSync(expand(controller.port_file), 'utf8').trim());
|
|
62
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) throw new Error('The controller has no valid retained port.');
|
|
63
|
+
const url = `http://127.0.0.1:${port}/health`;
|
|
64
|
+
const health = JSON.parse(run('curl', ['--fail', '--silent', '--show-error', '--max-time', '2', url], checkout));
|
|
65
|
+
if (!health.alive || !health.cdp_connected || health.restart_required !== false || health.controller?.source_hash !== sourceHash || health.installed_source_hash !== sourceHash) throw new Error('The running browser controller has not loaded the committed installed code.');
|
|
66
|
+
Object.assign(state, { ready: true, workflow: 'installed browser controller', run_id: `${health.controller.pid}@${health.controller.started_at}`, status: 'completed', conclusion: 'success', deployed_sha: head, url, source_hash: sourceHash });
|
|
67
|
+
return state;
|
|
68
|
+
}
|
|
46
69
|
if (entry.params.completion_ci.keeper_repositories?.includes(repo)) {
|
|
47
70
|
const receiptPath = join(board.root, 'runtime-deployment.json');
|
|
48
71
|
const receipt = JSON.parse(readFileSync(receiptPath, 'utf8'));
|
|
@@ -55,22 +78,43 @@ export function observeCompletionEvidence(board, id, entry, payload = {}) {
|
|
|
55
78
|
}
|
|
56
79
|
const configured = entry.params.completion_ci.workflows?.[repo] ?? entry.params.completion_ci.workflows?.['*'];
|
|
57
80
|
if (!Array.isArray(configured) || !configured.length) throw new Error(`No deployment workflow is declared for ${repo} in completion_ci.workflows.`);
|
|
58
|
-
const matchedRules = (entry.params.completion_ci.path_workflows?.[repo] ?? []).
|
|
59
|
-
records.
|
|
60
|
-
|
|
81
|
+
const matchedRules = (entry.params.completion_ci.path_workflows?.[repo] ?? []).map(rule => ({ ...rule,
|
|
82
|
+
changed_at: records.find(([, , names]) => names.split('\n').some(path => rule.paths.some(prefix => path.startsWith(prefix))))?.[1]
|
|
83
|
+
})).filter(rule => rule.changed_at);
|
|
61
84
|
const requestedRun = payload.ci_run ?? payload['ci-run'] ?? payload.metadata?.ci_run ?? (old?.commit === commit ? old?.run_id : null);
|
|
62
85
|
let receipt;
|
|
63
86
|
if (requestedRun) {
|
|
64
87
|
receipt = JSON.parse(run('gh', ['run', 'view', String(requestedRun), '--repo', repo, '--json', 'databaseId,workflowName,headSha,status,conclusion,url'], path));
|
|
65
88
|
} else {
|
|
66
89
|
const runs = JSON.parse(run('gh', ['run', 'list', '--repo', repo, '--commit', commit, '--limit', '100', '--json', 'databaseId,workflowName,headSha,status,conclusion,url'], path));
|
|
67
|
-
receipt = runs.find(row =>
|
|
90
|
+
receipt = runs.find(row => configured.includes(row.workflowName));
|
|
68
91
|
}
|
|
69
92
|
if (!receipt) throw new Error(`No deployment CI run exists for ${repo}@${commit}.`);
|
|
70
93
|
Object.assign(state, { run_id: receipt.databaseId, workflow: receipt.workflowName, status: receipt.status, conclusion: receipt.conclusion, url: receipt.url });
|
|
71
94
|
if (receipt.headSha !== commit) throw new Error(`CI run ${receipt.databaseId} is for ${receipt.headSha}, not ${commit}.`);
|
|
72
|
-
if (!
|
|
95
|
+
if (!configured.includes(receipt.workflowName)) throw new Error(`${receipt.workflowName} is not a declared deployment workflow for ${repo}.`);
|
|
73
96
|
if (receipt.status !== 'completed' || receipt.conclusion !== 'success') throw new Error(`Deployment CI ${receipt.databaseId} is ${receipt.status}/${receipt.conclusion || 'pending'}.`);
|
|
97
|
+
// A later SDK publication need not rebuild unchanged native code. It does
|
|
98
|
+
// need a successful native deployment containing this task's native changes.
|
|
99
|
+
// Retain each artifact's actual SHA, rather than calling the SDK run a native release.
|
|
100
|
+
state.coverage = [];
|
|
101
|
+
let successful;
|
|
102
|
+
for (const rule of matchedRules) {
|
|
103
|
+
if (rule.workflows.includes(receipt.workflowName)) continue;
|
|
104
|
+
successful ??= JSON.parse(run('gh', ['run', 'list', '--repo', repo, '--status', 'success', '--limit', '100', '--json', 'databaseId,workflowName,headSha,status,conclusion,url'], path));
|
|
105
|
+
const covering = successful.find(row => {
|
|
106
|
+
if (!rule.workflows.includes(row.workflowName) || !configured.includes(row.workflowName)) return false;
|
|
107
|
+
try {
|
|
108
|
+
run('git', ['merge-base', '--is-ancestor', rule.changed_at, row.headSha], path);
|
|
109
|
+
run('git', ['merge-base', '--is-ancestor', row.headSha, commit], path);
|
|
110
|
+
// Any later change in these paths requires another native deployment,
|
|
111
|
+
// even when a different task authored that change.
|
|
112
|
+
return run('git', ['diff', '--name-only', row.headSha, commit], path).split('\n').every(name => !rule.paths.some(prefix => name.startsWith(prefix)));
|
|
113
|
+
} catch { return false; }
|
|
114
|
+
});
|
|
115
|
+
if (!covering) throw new Error(`No successful ${rule.workflows.join('/')} deployment covers ${rule.paths.join(', ')} through ${commit}.`);
|
|
116
|
+
state.coverage.push({ paths: rule.paths, commit: covering.headSha, workflow: covering.workflowName, run_id: covering.databaseId, conclusion: covering.conclusion, url: covering.url });
|
|
117
|
+
}
|
|
74
118
|
state.deployed_sha = commit;
|
|
75
119
|
state.ready = true;
|
|
76
120
|
state.reason = null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volter/supercode-orchestrator",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.135",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The orchestrator runtime over the Volter Harness ontology: one typed operational model whose folder is its serialization, read and written through the harness orchestration doors (docs/ORCHESTRATOR-IR.md)",
|
|
6
6
|
"exports": {
|