@volter/supercode-orchestrator 0.4.133 → 0.4.134

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.
Files changed (2) hide show
  1. package/board/ci.mjs +24 -1
  2. 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'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/supercode-orchestrator",
3
- "version": "0.4.133",
3
+ "version": "0.4.134",
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": {