reporting-governance: tighten runtime route matrix
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { executeGovernanceContract } from './execute-governance-contract.mjs';
|
||||
import { runOrchestratorAdapter } from '../adapters/orchestrator.mjs';
|
||||
|
||||
const ACTION_ADAPTER_ROUTING = Object.freeze({
|
||||
const ADAPTER_ACTION_RUNNER_ROUTES = Object.freeze({
|
||||
notify_operator: {
|
||||
adapter: 'orchestrator',
|
||||
reason: 'deployment binding + adapter action routed into orchestrator adapter',
|
||||
reason: 'adapter_action notify_operator routed to orchestrator adapter runner',
|
||||
run: ({ governance, repoRootOverride, runtime }) => runOrchestratorAdapter({
|
||||
deploymentBinding: governance.deploymentBinding,
|
||||
repoRootOverride,
|
||||
@@ -13,35 +13,27 @@ const ACTION_ADAPTER_ROUTING = Object.freeze({
|
||||
},
|
||||
});
|
||||
|
||||
function createNotAttemptedResult(reason) {
|
||||
return {
|
||||
attempted: false,
|
||||
adapter: null,
|
||||
action: null,
|
||||
reason,
|
||||
runtimeExecution: null,
|
||||
};
|
||||
}
|
||||
|
||||
function resolveRuntimeRoute({ governance, runtime, repoRootOverride }) {
|
||||
if (!runtime) {
|
||||
return {
|
||||
attempted: false,
|
||||
adapter: null,
|
||||
action: null,
|
||||
reason: 'runtime execution not attempted',
|
||||
runtimeExecution: null,
|
||||
};
|
||||
return createNotAttemptedResult('runtime execution not attempted');
|
||||
}
|
||||
|
||||
if (governance.preflight?.status !== 'pass') {
|
||||
return {
|
||||
attempted: false,
|
||||
adapter: null,
|
||||
action: null,
|
||||
reason: 'runtime execution not attempted: compatibility preflight did not pass',
|
||||
runtimeExecution: null,
|
||||
};
|
||||
return createNotAttemptedResult('runtime execution not attempted: compatibility preflight did not pass');
|
||||
}
|
||||
|
||||
if (!governance.deploymentBinding) {
|
||||
return {
|
||||
attempted: false,
|
||||
adapter: null,
|
||||
action: null,
|
||||
reason: 'runtime execution not attempted: deployment binding is missing',
|
||||
runtimeExecution: null,
|
||||
};
|
||||
return createNotAttemptedResult('runtime execution not attempted: deployment binding is missing');
|
||||
}
|
||||
|
||||
const adapterActions = Array.isArray(governance.contract?.adapter_actions)
|
||||
@@ -49,7 +41,7 @@ function resolveRuntimeRoute({ governance, runtime, repoRootOverride }) {
|
||||
: [];
|
||||
|
||||
for (const action of adapterActions) {
|
||||
const route = ACTION_ADAPTER_ROUTING[action];
|
||||
const route = ADAPTER_ACTION_RUNNER_ROUTES[action];
|
||||
if (!route) continue;
|
||||
|
||||
return {
|
||||
@@ -61,13 +53,7 @@ function resolveRuntimeRoute({ governance, runtime, repoRootOverride }) {
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
attempted: false,
|
||||
adapter: null,
|
||||
action: null,
|
||||
reason: 'runtime execution not attempted: no routed adapter action matched runtime integration table',
|
||||
runtimeExecution: null,
|
||||
};
|
||||
return createNotAttemptedResult('runtime execution not attempted: no adapter_action matched an adapter runner route');
|
||||
}
|
||||
|
||||
export function executeRuntimeIntegratedGovernance({
|
||||
@@ -111,6 +97,7 @@ export function executeRuntimeIntegratedGovernance({
|
||||
}
|
||||
|
||||
export const __testables = {
|
||||
ACTION_ADAPTER_ROUTING,
|
||||
ADAPTER_ACTION_RUNNER_ROUTES,
|
||||
createNotAttemptedResult,
|
||||
resolveRuntimeRoute,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user