chainlesschain 0.145.0 → 0.152.0
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/package.json +1 -1
- package/src/commands/activitypub.js +207 -0
- package/src/commands/agent-network.js +217 -0
- package/src/commands/automation.js +201 -0
- package/src/commands/bi.js +203 -0
- package/src/commands/browse.js +213 -0
- package/src/commands/codegen.js +207 -0
- package/src/commands/collab.js +211 -0
- package/src/commands/compliance.js +410 -0
- package/src/commands/cowork.js +203 -0
- package/src/commands/dbevo.js +227 -0
- package/src/commands/dev.js +207 -0
- package/src/commands/did-v2.js +217 -0
- package/src/commands/did.js +221 -0
- package/src/commands/dlp.js +213 -0
- package/src/commands/evomap.js +205 -0
- package/src/commands/export.js +213 -0
- package/src/commands/federation.js +209 -0
- package/src/commands/fusion.js +205 -0
- package/src/commands/governance.js +209 -0
- package/src/commands/hook.js +209 -0
- package/src/commands/import.js +209 -0
- package/src/commands/infra.js +203 -0
- package/src/commands/instinct.js +209 -0
- package/src/commands/ipfs.js +207 -0
- package/src/commands/llm.js +217 -0
- package/src/commands/matrix.js +207 -0
- package/src/commands/mcp.js +217 -0
- package/src/commands/memory.js +209 -0
- package/src/commands/multimodal.js +203 -0
- package/src/commands/nlprog.js +225 -0
- package/src/commands/nostr.js +209 -0
- package/src/commands/note.js +205 -0
- package/src/commands/ops.js +219 -0
- package/src/commands/org.js +209 -0
- package/src/commands/p2p.js +209 -0
- package/src/commands/perception.js +209 -0
- package/src/commands/permmem.js +203 -0
- package/src/commands/plugin-ecosystem.js +209 -0
- package/src/commands/pqc.js +213 -0
- package/src/commands/quantization.js +207 -0
- package/src/commands/rcache.js +205 -0
- package/src/commands/recommend.js +233 -0
- package/src/commands/runtime.js +205 -0
- package/src/commands/scim.js +209 -0
- package/src/commands/session.js +209 -0
- package/src/commands/skill.js +207 -0
- package/src/commands/social.js +201 -0
- package/src/commands/sso.js +209 -0
- package/src/commands/sync.js +209 -0
- package/src/commands/tech.js +209 -0
- package/src/commands/tenant.js +217 -0
- package/src/commands/tokens.js +209 -0
- package/src/commands/trust.js +217 -0
- package/src/commands/wallet.js +209 -0
- package/src/commands/workflow.js +203 -0
- package/src/index.js +140 -0
- package/src/lib/activitypub-bridge.js +334 -0
- package/src/lib/agent-network.js +341 -0
- package/src/lib/aiops.js +346 -0
- package/src/lib/automation-engine.js +335 -0
- package/src/lib/autonomous-developer.js +332 -0
- package/src/lib/bi-engine.js +333 -0
- package/src/lib/browser-automation.js +334 -0
- package/src/lib/code-agent.js +339 -0
- package/src/lib/collaboration-governance.js +334 -0
- package/src/lib/community-governance.js +346 -0
- package/src/lib/content-recommendation.js +351 -0
- package/src/lib/cowork-share.js +338 -0
- package/src/lib/dbevo.js +351 -0
- package/src/lib/decentral-infra.js +330 -0
- package/src/lib/did-manager.js +341 -0
- package/src/lib/did-v2-manager.js +341 -0
- package/src/lib/dlp-engine.js +339 -0
- package/src/lib/evomap-governance.js +334 -0
- package/src/lib/federation-hardening.js +340 -0
- package/src/lib/hook-manager.js +341 -0
- package/src/lib/instinct-manager.js +346 -0
- package/src/lib/ipfs-storage.js +334 -0
- package/src/lib/knowledge-exporter.js +341 -0
- package/src/lib/knowledge-importer.js +341 -0
- package/src/lib/llm-providers.js +346 -0
- package/src/lib/matrix-bridge.js +339 -0
- package/src/lib/mcp-registry.js +346 -0
- package/src/lib/memory-manager.js +336 -0
- package/src/lib/multimodal.js +330 -0
- package/src/lib/nl-programming.js +341 -0
- package/src/lib/nostr-bridge.js +336 -0
- package/src/lib/note-versioning.js +339 -0
- package/src/lib/org-manager.js +336 -0
- package/src/lib/p2p-manager.js +341 -0
- package/src/lib/perception.js +346 -0
- package/src/lib/permanent-memory.js +327 -0
- package/src/lib/plugin-ecosystem.js +346 -0
- package/src/lib/pqc-manager.js +346 -0
- package/src/lib/protocol-fusion.js +338 -0
- package/src/lib/quantization.js +337 -0
- package/src/lib/response-cache.js +333 -0
- package/src/lib/scim-manager.js +346 -0
- package/src/lib/session-manager.js +334 -0
- package/src/lib/skill-loader.js +334 -0
- package/src/lib/social-manager.js +330 -0
- package/src/lib/sso-manager.js +340 -0
- package/src/lib/sync-manager.js +336 -0
- package/src/lib/tech-learning-engine.js +341 -0
- package/src/lib/tenant-saas.js +341 -0
- package/src/lib/threat-intel.js +330 -0
- package/src/lib/token-tracker.js +336 -0
- package/src/lib/trust-security.js +343 -0
- package/src/lib/ueba.js +340 -0
- package/src/lib/universal-runtime.js +330 -0
- package/src/lib/wallet-manager.js +336 -0
- package/src/lib/workflow-engine.js +330 -0
package/src/lib/aiops.js
CHANGED
|
@@ -999,3 +999,349 @@ export function _resetStateV2() {
|
|
|
999
999
|
_playbookStaleMsV2 = AIOPS_DEFAULT_PLAYBOOK_STALE_MS;
|
|
1000
1000
|
_remediationTimeoutMsV2 = AIOPS_DEFAULT_REMEDIATION_TIMEOUT_MS;
|
|
1001
1001
|
}
|
|
1002
|
+
|
|
1003
|
+
// =====================================================================
|
|
1004
|
+
// aiops V2 governance overlay (iter18)
|
|
1005
|
+
// =====================================================================
|
|
1006
|
+
export const AIOPSGOV_PROFILE_MATURITY_V2 = Object.freeze({
|
|
1007
|
+
PENDING: "pending",
|
|
1008
|
+
ACTIVE: "active",
|
|
1009
|
+
STALE: "stale",
|
|
1010
|
+
ARCHIVED: "archived",
|
|
1011
|
+
});
|
|
1012
|
+
export const AIOPSGOV_INCIDENT_LIFECYCLE_V2 = Object.freeze({
|
|
1013
|
+
QUEUED: "queued",
|
|
1014
|
+
TRIAGING: "triaging",
|
|
1015
|
+
TRIAGED: "triaged",
|
|
1016
|
+
FAILED: "failed",
|
|
1017
|
+
CANCELLED: "cancelled",
|
|
1018
|
+
});
|
|
1019
|
+
const _aiopsgovPTrans = new Map([
|
|
1020
|
+
[
|
|
1021
|
+
AIOPSGOV_PROFILE_MATURITY_V2.PENDING,
|
|
1022
|
+
new Set([
|
|
1023
|
+
AIOPSGOV_PROFILE_MATURITY_V2.ACTIVE,
|
|
1024
|
+
AIOPSGOV_PROFILE_MATURITY_V2.ARCHIVED,
|
|
1025
|
+
]),
|
|
1026
|
+
],
|
|
1027
|
+
[
|
|
1028
|
+
AIOPSGOV_PROFILE_MATURITY_V2.ACTIVE,
|
|
1029
|
+
new Set([
|
|
1030
|
+
AIOPSGOV_PROFILE_MATURITY_V2.STALE,
|
|
1031
|
+
AIOPSGOV_PROFILE_MATURITY_V2.ARCHIVED,
|
|
1032
|
+
]),
|
|
1033
|
+
],
|
|
1034
|
+
[
|
|
1035
|
+
AIOPSGOV_PROFILE_MATURITY_V2.STALE,
|
|
1036
|
+
new Set([
|
|
1037
|
+
AIOPSGOV_PROFILE_MATURITY_V2.ACTIVE,
|
|
1038
|
+
AIOPSGOV_PROFILE_MATURITY_V2.ARCHIVED,
|
|
1039
|
+
]),
|
|
1040
|
+
],
|
|
1041
|
+
[AIOPSGOV_PROFILE_MATURITY_V2.ARCHIVED, new Set()],
|
|
1042
|
+
]);
|
|
1043
|
+
const _aiopsgovPTerminal = new Set([AIOPSGOV_PROFILE_MATURITY_V2.ARCHIVED]);
|
|
1044
|
+
const _aiopsgovJTrans = new Map([
|
|
1045
|
+
[
|
|
1046
|
+
AIOPSGOV_INCIDENT_LIFECYCLE_V2.QUEUED,
|
|
1047
|
+
new Set([
|
|
1048
|
+
AIOPSGOV_INCIDENT_LIFECYCLE_V2.TRIAGING,
|
|
1049
|
+
AIOPSGOV_INCIDENT_LIFECYCLE_V2.CANCELLED,
|
|
1050
|
+
]),
|
|
1051
|
+
],
|
|
1052
|
+
[
|
|
1053
|
+
AIOPSGOV_INCIDENT_LIFECYCLE_V2.TRIAGING,
|
|
1054
|
+
new Set([
|
|
1055
|
+
AIOPSGOV_INCIDENT_LIFECYCLE_V2.TRIAGED,
|
|
1056
|
+
AIOPSGOV_INCIDENT_LIFECYCLE_V2.FAILED,
|
|
1057
|
+
AIOPSGOV_INCIDENT_LIFECYCLE_V2.CANCELLED,
|
|
1058
|
+
]),
|
|
1059
|
+
],
|
|
1060
|
+
[AIOPSGOV_INCIDENT_LIFECYCLE_V2.TRIAGED, new Set()],
|
|
1061
|
+
[AIOPSGOV_INCIDENT_LIFECYCLE_V2.FAILED, new Set()],
|
|
1062
|
+
[AIOPSGOV_INCIDENT_LIFECYCLE_V2.CANCELLED, new Set()],
|
|
1063
|
+
]);
|
|
1064
|
+
const _aiopsgovPsV2 = new Map();
|
|
1065
|
+
const _aiopsgovJsV2 = new Map();
|
|
1066
|
+
let _aiopsgovMaxActive = 6,
|
|
1067
|
+
_aiopsgovMaxPending = 15,
|
|
1068
|
+
_aiopsgovIdleMs = 30 * 24 * 60 * 60 * 1000,
|
|
1069
|
+
_aiopsgovStuckMs = 60 * 1000;
|
|
1070
|
+
function _aiopsgovPos(n, label) {
|
|
1071
|
+
const v = Math.floor(Number(n));
|
|
1072
|
+
if (!Number.isFinite(v) || v <= 0)
|
|
1073
|
+
throw new Error(`${label} must be positive integer`);
|
|
1074
|
+
return v;
|
|
1075
|
+
}
|
|
1076
|
+
function _aiopsgovCheckP(from, to) {
|
|
1077
|
+
const a = _aiopsgovPTrans.get(from);
|
|
1078
|
+
if (!a || !a.has(to))
|
|
1079
|
+
throw new Error(`invalid aiopsgov profile transition ${from} → ${to}`);
|
|
1080
|
+
}
|
|
1081
|
+
function _aiopsgovCheckJ(from, to) {
|
|
1082
|
+
const a = _aiopsgovJTrans.get(from);
|
|
1083
|
+
if (!a || !a.has(to))
|
|
1084
|
+
throw new Error(`invalid aiopsgov incident transition ${from} → ${to}`);
|
|
1085
|
+
}
|
|
1086
|
+
function _aiopsgovCountActive(owner) {
|
|
1087
|
+
let c = 0;
|
|
1088
|
+
for (const p of _aiopsgovPsV2.values())
|
|
1089
|
+
if (p.owner === owner && p.status === AIOPSGOV_PROFILE_MATURITY_V2.ACTIVE)
|
|
1090
|
+
c++;
|
|
1091
|
+
return c;
|
|
1092
|
+
}
|
|
1093
|
+
function _aiopsgovCountPending(profileId) {
|
|
1094
|
+
let c = 0;
|
|
1095
|
+
for (const j of _aiopsgovJsV2.values())
|
|
1096
|
+
if (
|
|
1097
|
+
j.profileId === profileId &&
|
|
1098
|
+
(j.status === AIOPSGOV_INCIDENT_LIFECYCLE_V2.QUEUED ||
|
|
1099
|
+
j.status === AIOPSGOV_INCIDENT_LIFECYCLE_V2.TRIAGING)
|
|
1100
|
+
)
|
|
1101
|
+
c++;
|
|
1102
|
+
return c;
|
|
1103
|
+
}
|
|
1104
|
+
export function setMaxActiveAiopsgovProfilesPerOwnerV2(n) {
|
|
1105
|
+
_aiopsgovMaxActive = _aiopsgovPos(n, "maxActiveAiopsgovProfilesPerOwner");
|
|
1106
|
+
}
|
|
1107
|
+
export function getMaxActiveAiopsgovProfilesPerOwnerV2() {
|
|
1108
|
+
return _aiopsgovMaxActive;
|
|
1109
|
+
}
|
|
1110
|
+
export function setMaxPendingAiopsgovIncidentsPerProfileV2(n) {
|
|
1111
|
+
_aiopsgovMaxPending = _aiopsgovPos(
|
|
1112
|
+
n,
|
|
1113
|
+
"maxPendingAiopsgovIncidentsPerProfile",
|
|
1114
|
+
);
|
|
1115
|
+
}
|
|
1116
|
+
export function getMaxPendingAiopsgovIncidentsPerProfileV2() {
|
|
1117
|
+
return _aiopsgovMaxPending;
|
|
1118
|
+
}
|
|
1119
|
+
export function setAiopsgovProfileIdleMsV2(n) {
|
|
1120
|
+
_aiopsgovIdleMs = _aiopsgovPos(n, "aiopsgovProfileIdleMs");
|
|
1121
|
+
}
|
|
1122
|
+
export function getAiopsgovProfileIdleMsV2() {
|
|
1123
|
+
return _aiopsgovIdleMs;
|
|
1124
|
+
}
|
|
1125
|
+
export function setAiopsgovIncidentStuckMsV2(n) {
|
|
1126
|
+
_aiopsgovStuckMs = _aiopsgovPos(n, "aiopsgovIncidentStuckMs");
|
|
1127
|
+
}
|
|
1128
|
+
export function getAiopsgovIncidentStuckMsV2() {
|
|
1129
|
+
return _aiopsgovStuckMs;
|
|
1130
|
+
}
|
|
1131
|
+
export function _resetStateAiopsGovV2() {
|
|
1132
|
+
_aiopsgovPsV2.clear();
|
|
1133
|
+
_aiopsgovJsV2.clear();
|
|
1134
|
+
_aiopsgovMaxActive = 6;
|
|
1135
|
+
_aiopsgovMaxPending = 15;
|
|
1136
|
+
_aiopsgovIdleMs = 30 * 24 * 60 * 60 * 1000;
|
|
1137
|
+
_aiopsgovStuckMs = 60 * 1000;
|
|
1138
|
+
}
|
|
1139
|
+
export function registerAiopsgovProfileV2({ id, owner, mode, metadata } = {}) {
|
|
1140
|
+
if (!id || !owner) throw new Error("id and owner required");
|
|
1141
|
+
if (_aiopsgovPsV2.has(id))
|
|
1142
|
+
throw new Error(`aiopsgov profile ${id} already exists`);
|
|
1143
|
+
const now = Date.now();
|
|
1144
|
+
const p = {
|
|
1145
|
+
id,
|
|
1146
|
+
owner,
|
|
1147
|
+
mode: mode || "monitor",
|
|
1148
|
+
status: AIOPSGOV_PROFILE_MATURITY_V2.PENDING,
|
|
1149
|
+
createdAt: now,
|
|
1150
|
+
updatedAt: now,
|
|
1151
|
+
lastTouchedAt: now,
|
|
1152
|
+
activatedAt: null,
|
|
1153
|
+
archivedAt: null,
|
|
1154
|
+
metadata: { ...(metadata || {}) },
|
|
1155
|
+
};
|
|
1156
|
+
_aiopsgovPsV2.set(id, p);
|
|
1157
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
1158
|
+
}
|
|
1159
|
+
export function activateAiopsgovProfileV2(id) {
|
|
1160
|
+
const p = _aiopsgovPsV2.get(id);
|
|
1161
|
+
if (!p) throw new Error(`aiopsgov profile ${id} not found`);
|
|
1162
|
+
const isInitial = p.status === AIOPSGOV_PROFILE_MATURITY_V2.PENDING;
|
|
1163
|
+
_aiopsgovCheckP(p.status, AIOPSGOV_PROFILE_MATURITY_V2.ACTIVE);
|
|
1164
|
+
if (isInitial && _aiopsgovCountActive(p.owner) >= _aiopsgovMaxActive)
|
|
1165
|
+
throw new Error(
|
|
1166
|
+
`max active aiopsgov profiles for owner ${p.owner} reached`,
|
|
1167
|
+
);
|
|
1168
|
+
const now = Date.now();
|
|
1169
|
+
p.status = AIOPSGOV_PROFILE_MATURITY_V2.ACTIVE;
|
|
1170
|
+
p.updatedAt = now;
|
|
1171
|
+
p.lastTouchedAt = now;
|
|
1172
|
+
if (!p.activatedAt) p.activatedAt = now;
|
|
1173
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
1174
|
+
}
|
|
1175
|
+
export function staleAiopsgovProfileV2(id) {
|
|
1176
|
+
const p = _aiopsgovPsV2.get(id);
|
|
1177
|
+
if (!p) throw new Error(`aiopsgov profile ${id} not found`);
|
|
1178
|
+
_aiopsgovCheckP(p.status, AIOPSGOV_PROFILE_MATURITY_V2.STALE);
|
|
1179
|
+
p.status = AIOPSGOV_PROFILE_MATURITY_V2.STALE;
|
|
1180
|
+
p.updatedAt = Date.now();
|
|
1181
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
1182
|
+
}
|
|
1183
|
+
export function archiveAiopsgovProfileV2(id) {
|
|
1184
|
+
const p = _aiopsgovPsV2.get(id);
|
|
1185
|
+
if (!p) throw new Error(`aiopsgov profile ${id} not found`);
|
|
1186
|
+
_aiopsgovCheckP(p.status, AIOPSGOV_PROFILE_MATURITY_V2.ARCHIVED);
|
|
1187
|
+
const now = Date.now();
|
|
1188
|
+
p.status = AIOPSGOV_PROFILE_MATURITY_V2.ARCHIVED;
|
|
1189
|
+
p.updatedAt = now;
|
|
1190
|
+
if (!p.archivedAt) p.archivedAt = now;
|
|
1191
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
1192
|
+
}
|
|
1193
|
+
export function touchAiopsgovProfileV2(id) {
|
|
1194
|
+
const p = _aiopsgovPsV2.get(id);
|
|
1195
|
+
if (!p) throw new Error(`aiopsgov profile ${id} not found`);
|
|
1196
|
+
if (_aiopsgovPTerminal.has(p.status))
|
|
1197
|
+
throw new Error(`cannot touch terminal aiopsgov profile ${id}`);
|
|
1198
|
+
const now = Date.now();
|
|
1199
|
+
p.lastTouchedAt = now;
|
|
1200
|
+
p.updatedAt = now;
|
|
1201
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
1202
|
+
}
|
|
1203
|
+
export function getAiopsgovProfileV2(id) {
|
|
1204
|
+
const p = _aiopsgovPsV2.get(id);
|
|
1205
|
+
if (!p) return null;
|
|
1206
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
1207
|
+
}
|
|
1208
|
+
export function listAiopsgovProfilesV2() {
|
|
1209
|
+
return [..._aiopsgovPsV2.values()].map((p) => ({
|
|
1210
|
+
...p,
|
|
1211
|
+
metadata: { ...p.metadata },
|
|
1212
|
+
}));
|
|
1213
|
+
}
|
|
1214
|
+
export function createAiopsgovIncidentV2({
|
|
1215
|
+
id,
|
|
1216
|
+
profileId,
|
|
1217
|
+
summary,
|
|
1218
|
+
metadata,
|
|
1219
|
+
} = {}) {
|
|
1220
|
+
if (!id || !profileId) throw new Error("id and profileId required");
|
|
1221
|
+
if (_aiopsgovJsV2.has(id))
|
|
1222
|
+
throw new Error(`aiopsgov incident ${id} already exists`);
|
|
1223
|
+
if (!_aiopsgovPsV2.has(profileId))
|
|
1224
|
+
throw new Error(`aiopsgov profile ${profileId} not found`);
|
|
1225
|
+
if (_aiopsgovCountPending(profileId) >= _aiopsgovMaxPending)
|
|
1226
|
+
throw new Error(
|
|
1227
|
+
`max pending aiopsgov incidents for profile ${profileId} reached`,
|
|
1228
|
+
);
|
|
1229
|
+
const now = Date.now();
|
|
1230
|
+
const j = {
|
|
1231
|
+
id,
|
|
1232
|
+
profileId,
|
|
1233
|
+
summary: summary || "",
|
|
1234
|
+
status: AIOPSGOV_INCIDENT_LIFECYCLE_V2.QUEUED,
|
|
1235
|
+
createdAt: now,
|
|
1236
|
+
updatedAt: now,
|
|
1237
|
+
startedAt: null,
|
|
1238
|
+
settledAt: null,
|
|
1239
|
+
metadata: { ...(metadata || {}) },
|
|
1240
|
+
};
|
|
1241
|
+
_aiopsgovJsV2.set(id, j);
|
|
1242
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
1243
|
+
}
|
|
1244
|
+
export function triagingAiopsgovIncidentV2(id) {
|
|
1245
|
+
const j = _aiopsgovJsV2.get(id);
|
|
1246
|
+
if (!j) throw new Error(`aiopsgov incident ${id} not found`);
|
|
1247
|
+
_aiopsgovCheckJ(j.status, AIOPSGOV_INCIDENT_LIFECYCLE_V2.TRIAGING);
|
|
1248
|
+
const now = Date.now();
|
|
1249
|
+
j.status = AIOPSGOV_INCIDENT_LIFECYCLE_V2.TRIAGING;
|
|
1250
|
+
j.updatedAt = now;
|
|
1251
|
+
if (!j.startedAt) j.startedAt = now;
|
|
1252
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
1253
|
+
}
|
|
1254
|
+
export function completeIncidentAiopsgovV2(id) {
|
|
1255
|
+
const j = _aiopsgovJsV2.get(id);
|
|
1256
|
+
if (!j) throw new Error(`aiopsgov incident ${id} not found`);
|
|
1257
|
+
_aiopsgovCheckJ(j.status, AIOPSGOV_INCIDENT_LIFECYCLE_V2.TRIAGED);
|
|
1258
|
+
const now = Date.now();
|
|
1259
|
+
j.status = AIOPSGOV_INCIDENT_LIFECYCLE_V2.TRIAGED;
|
|
1260
|
+
j.updatedAt = now;
|
|
1261
|
+
if (!j.settledAt) j.settledAt = now;
|
|
1262
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
1263
|
+
}
|
|
1264
|
+
export function failAiopsgovIncidentV2(id, reason) {
|
|
1265
|
+
const j = _aiopsgovJsV2.get(id);
|
|
1266
|
+
if (!j) throw new Error(`aiopsgov incident ${id} not found`);
|
|
1267
|
+
_aiopsgovCheckJ(j.status, AIOPSGOV_INCIDENT_LIFECYCLE_V2.FAILED);
|
|
1268
|
+
const now = Date.now();
|
|
1269
|
+
j.status = AIOPSGOV_INCIDENT_LIFECYCLE_V2.FAILED;
|
|
1270
|
+
j.updatedAt = now;
|
|
1271
|
+
if (!j.settledAt) j.settledAt = now;
|
|
1272
|
+
if (reason) j.metadata.failReason = String(reason);
|
|
1273
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
1274
|
+
}
|
|
1275
|
+
export function cancelAiopsgovIncidentV2(id, reason) {
|
|
1276
|
+
const j = _aiopsgovJsV2.get(id);
|
|
1277
|
+
if (!j) throw new Error(`aiopsgov incident ${id} not found`);
|
|
1278
|
+
_aiopsgovCheckJ(j.status, AIOPSGOV_INCIDENT_LIFECYCLE_V2.CANCELLED);
|
|
1279
|
+
const now = Date.now();
|
|
1280
|
+
j.status = AIOPSGOV_INCIDENT_LIFECYCLE_V2.CANCELLED;
|
|
1281
|
+
j.updatedAt = now;
|
|
1282
|
+
if (!j.settledAt) j.settledAt = now;
|
|
1283
|
+
if (reason) j.metadata.cancelReason = String(reason);
|
|
1284
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
1285
|
+
}
|
|
1286
|
+
export function getAiopsgovIncidentV2(id) {
|
|
1287
|
+
const j = _aiopsgovJsV2.get(id);
|
|
1288
|
+
if (!j) return null;
|
|
1289
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
1290
|
+
}
|
|
1291
|
+
export function listAiopsgovIncidentsV2() {
|
|
1292
|
+
return [..._aiopsgovJsV2.values()].map((j) => ({
|
|
1293
|
+
...j,
|
|
1294
|
+
metadata: { ...j.metadata },
|
|
1295
|
+
}));
|
|
1296
|
+
}
|
|
1297
|
+
export function autoStaleIdleAiopsgovProfilesV2({ now } = {}) {
|
|
1298
|
+
const t = now ?? Date.now();
|
|
1299
|
+
const flipped = [];
|
|
1300
|
+
for (const p of _aiopsgovPsV2.values())
|
|
1301
|
+
if (
|
|
1302
|
+
p.status === AIOPSGOV_PROFILE_MATURITY_V2.ACTIVE &&
|
|
1303
|
+
t - p.lastTouchedAt >= _aiopsgovIdleMs
|
|
1304
|
+
) {
|
|
1305
|
+
p.status = AIOPSGOV_PROFILE_MATURITY_V2.STALE;
|
|
1306
|
+
p.updatedAt = t;
|
|
1307
|
+
flipped.push(p.id);
|
|
1308
|
+
}
|
|
1309
|
+
return { flipped, count: flipped.length };
|
|
1310
|
+
}
|
|
1311
|
+
export function autoFailStuckAiopsgovIncidentsV2({ now } = {}) {
|
|
1312
|
+
const t = now ?? Date.now();
|
|
1313
|
+
const flipped = [];
|
|
1314
|
+
for (const j of _aiopsgovJsV2.values())
|
|
1315
|
+
if (
|
|
1316
|
+
j.status === AIOPSGOV_INCIDENT_LIFECYCLE_V2.TRIAGING &&
|
|
1317
|
+
j.startedAt != null &&
|
|
1318
|
+
t - j.startedAt >= _aiopsgovStuckMs
|
|
1319
|
+
) {
|
|
1320
|
+
j.status = AIOPSGOV_INCIDENT_LIFECYCLE_V2.FAILED;
|
|
1321
|
+
j.updatedAt = t;
|
|
1322
|
+
if (!j.settledAt) j.settledAt = t;
|
|
1323
|
+
j.metadata.failReason = "auto-fail-stuck";
|
|
1324
|
+
flipped.push(j.id);
|
|
1325
|
+
}
|
|
1326
|
+
return { flipped, count: flipped.length };
|
|
1327
|
+
}
|
|
1328
|
+
export function getAiopsGovStatsV2() {
|
|
1329
|
+
const profilesByStatus = {};
|
|
1330
|
+
for (const v of Object.values(AIOPSGOV_PROFILE_MATURITY_V2))
|
|
1331
|
+
profilesByStatus[v] = 0;
|
|
1332
|
+
for (const p of _aiopsgovPsV2.values()) profilesByStatus[p.status]++;
|
|
1333
|
+
const incidentsByStatus = {};
|
|
1334
|
+
for (const v of Object.values(AIOPSGOV_INCIDENT_LIFECYCLE_V2))
|
|
1335
|
+
incidentsByStatus[v] = 0;
|
|
1336
|
+
for (const j of _aiopsgovJsV2.values()) incidentsByStatus[j.status]++;
|
|
1337
|
+
return {
|
|
1338
|
+
totalAiopsgovProfilesV2: _aiopsgovPsV2.size,
|
|
1339
|
+
totalAiopsgovIncidentsV2: _aiopsgovJsV2.size,
|
|
1340
|
+
maxActiveAiopsgovProfilesPerOwner: _aiopsgovMaxActive,
|
|
1341
|
+
maxPendingAiopsgovIncidentsPerProfile: _aiopsgovMaxPending,
|
|
1342
|
+
aiopsgovProfileIdleMs: _aiopsgovIdleMs,
|
|
1343
|
+
aiopsgovIncidentStuckMs: _aiopsgovStuckMs,
|
|
1344
|
+
profilesByStatus,
|
|
1345
|
+
incidentsByStatus,
|
|
1346
|
+
};
|
|
1347
|
+
}
|
|
@@ -1276,3 +1276,338 @@ export function _resetStateAutomationEngineV2() {
|
|
|
1276
1276
|
_automationIdleMsV2 = AUTOMATION_DEFAULT_AUTOMATION_IDLE_MS;
|
|
1277
1277
|
_executionStuckMsV2 = AUTOMATION_DEFAULT_EXECUTION_STUCK_MS;
|
|
1278
1278
|
}
|
|
1279
|
+
|
|
1280
|
+
// =====================================================================
|
|
1281
|
+
// automation-engine V2 governance overlay (iter22)
|
|
1282
|
+
// =====================================================================
|
|
1283
|
+
export const AUGOV_PROFILE_MATURITY_V2 = Object.freeze({
|
|
1284
|
+
PENDING: "pending",
|
|
1285
|
+
ACTIVE: "active",
|
|
1286
|
+
PAUSED: "paused",
|
|
1287
|
+
ARCHIVED: "archived",
|
|
1288
|
+
});
|
|
1289
|
+
export const AUGOV_FLOW_LIFECYCLE_V2 = Object.freeze({
|
|
1290
|
+
QUEUED: "queued",
|
|
1291
|
+
RUNNING: "running",
|
|
1292
|
+
COMPLETED: "completed",
|
|
1293
|
+
FAILED: "failed",
|
|
1294
|
+
CANCELLED: "cancelled",
|
|
1295
|
+
});
|
|
1296
|
+
const _augovPTrans = new Map([
|
|
1297
|
+
[
|
|
1298
|
+
AUGOV_PROFILE_MATURITY_V2.PENDING,
|
|
1299
|
+
new Set([
|
|
1300
|
+
AUGOV_PROFILE_MATURITY_V2.ACTIVE,
|
|
1301
|
+
AUGOV_PROFILE_MATURITY_V2.ARCHIVED,
|
|
1302
|
+
]),
|
|
1303
|
+
],
|
|
1304
|
+
[
|
|
1305
|
+
AUGOV_PROFILE_MATURITY_V2.ACTIVE,
|
|
1306
|
+
new Set([
|
|
1307
|
+
AUGOV_PROFILE_MATURITY_V2.PAUSED,
|
|
1308
|
+
AUGOV_PROFILE_MATURITY_V2.ARCHIVED,
|
|
1309
|
+
]),
|
|
1310
|
+
],
|
|
1311
|
+
[
|
|
1312
|
+
AUGOV_PROFILE_MATURITY_V2.PAUSED,
|
|
1313
|
+
new Set([
|
|
1314
|
+
AUGOV_PROFILE_MATURITY_V2.ACTIVE,
|
|
1315
|
+
AUGOV_PROFILE_MATURITY_V2.ARCHIVED,
|
|
1316
|
+
]),
|
|
1317
|
+
],
|
|
1318
|
+
[AUGOV_PROFILE_MATURITY_V2.ARCHIVED, new Set()],
|
|
1319
|
+
]);
|
|
1320
|
+
const _augovPTerminal = new Set([AUGOV_PROFILE_MATURITY_V2.ARCHIVED]);
|
|
1321
|
+
const _augovJTrans = new Map([
|
|
1322
|
+
[
|
|
1323
|
+
AUGOV_FLOW_LIFECYCLE_V2.QUEUED,
|
|
1324
|
+
new Set([
|
|
1325
|
+
AUGOV_FLOW_LIFECYCLE_V2.RUNNING,
|
|
1326
|
+
AUGOV_FLOW_LIFECYCLE_V2.CANCELLED,
|
|
1327
|
+
]),
|
|
1328
|
+
],
|
|
1329
|
+
[
|
|
1330
|
+
AUGOV_FLOW_LIFECYCLE_V2.RUNNING,
|
|
1331
|
+
new Set([
|
|
1332
|
+
AUGOV_FLOW_LIFECYCLE_V2.COMPLETED,
|
|
1333
|
+
AUGOV_FLOW_LIFECYCLE_V2.FAILED,
|
|
1334
|
+
AUGOV_FLOW_LIFECYCLE_V2.CANCELLED,
|
|
1335
|
+
]),
|
|
1336
|
+
],
|
|
1337
|
+
[AUGOV_FLOW_LIFECYCLE_V2.COMPLETED, new Set()],
|
|
1338
|
+
[AUGOV_FLOW_LIFECYCLE_V2.FAILED, new Set()],
|
|
1339
|
+
[AUGOV_FLOW_LIFECYCLE_V2.CANCELLED, new Set()],
|
|
1340
|
+
]);
|
|
1341
|
+
const _augovPsV2 = new Map();
|
|
1342
|
+
const _augovJsV2 = new Map();
|
|
1343
|
+
let _augovMaxActive = 10,
|
|
1344
|
+
_augovMaxPending = 25,
|
|
1345
|
+
_augovIdleMs = 30 * 24 * 60 * 60 * 1000,
|
|
1346
|
+
_augovStuckMs = 60 * 1000;
|
|
1347
|
+
function _augovPos(n, label) {
|
|
1348
|
+
const v = Math.floor(Number(n));
|
|
1349
|
+
if (!Number.isFinite(v) || v <= 0)
|
|
1350
|
+
throw new Error(`${label} must be positive integer`);
|
|
1351
|
+
return v;
|
|
1352
|
+
}
|
|
1353
|
+
function _augovCheckP(from, to) {
|
|
1354
|
+
const a = _augovPTrans.get(from);
|
|
1355
|
+
if (!a || !a.has(to))
|
|
1356
|
+
throw new Error(`invalid augov profile transition ${from} → ${to}`);
|
|
1357
|
+
}
|
|
1358
|
+
function _augovCheckJ(from, to) {
|
|
1359
|
+
const a = _augovJTrans.get(from);
|
|
1360
|
+
if (!a || !a.has(to))
|
|
1361
|
+
throw new Error(`invalid augov flow transition ${from} → ${to}`);
|
|
1362
|
+
}
|
|
1363
|
+
function _augovCountActive(owner) {
|
|
1364
|
+
let c = 0;
|
|
1365
|
+
for (const p of _augovPsV2.values())
|
|
1366
|
+
if (p.owner === owner && p.status === AUGOV_PROFILE_MATURITY_V2.ACTIVE) c++;
|
|
1367
|
+
return c;
|
|
1368
|
+
}
|
|
1369
|
+
function _augovCountPending(profileId) {
|
|
1370
|
+
let c = 0;
|
|
1371
|
+
for (const j of _augovJsV2.values())
|
|
1372
|
+
if (
|
|
1373
|
+
j.profileId === profileId &&
|
|
1374
|
+
(j.status === AUGOV_FLOW_LIFECYCLE_V2.QUEUED ||
|
|
1375
|
+
j.status === AUGOV_FLOW_LIFECYCLE_V2.RUNNING)
|
|
1376
|
+
)
|
|
1377
|
+
c++;
|
|
1378
|
+
return c;
|
|
1379
|
+
}
|
|
1380
|
+
export function setMaxActiveAugovProfilesPerOwnerV2(n) {
|
|
1381
|
+
_augovMaxActive = _augovPos(n, "maxActiveAugovProfilesPerOwner");
|
|
1382
|
+
}
|
|
1383
|
+
export function getMaxActiveAugovProfilesPerOwnerV2() {
|
|
1384
|
+
return _augovMaxActive;
|
|
1385
|
+
}
|
|
1386
|
+
export function setMaxPendingAugovFlowsPerProfileV2(n) {
|
|
1387
|
+
_augovMaxPending = _augovPos(n, "maxPendingAugovFlowsPerProfile");
|
|
1388
|
+
}
|
|
1389
|
+
export function getMaxPendingAugovFlowsPerProfileV2() {
|
|
1390
|
+
return _augovMaxPending;
|
|
1391
|
+
}
|
|
1392
|
+
export function setAugovProfileIdleMsV2(n) {
|
|
1393
|
+
_augovIdleMs = _augovPos(n, "augovProfileIdleMs");
|
|
1394
|
+
}
|
|
1395
|
+
export function getAugovProfileIdleMsV2() {
|
|
1396
|
+
return _augovIdleMs;
|
|
1397
|
+
}
|
|
1398
|
+
export function setAugovFlowStuckMsV2(n) {
|
|
1399
|
+
_augovStuckMs = _augovPos(n, "augovFlowStuckMs");
|
|
1400
|
+
}
|
|
1401
|
+
export function getAugovFlowStuckMsV2() {
|
|
1402
|
+
return _augovStuckMs;
|
|
1403
|
+
}
|
|
1404
|
+
export function _resetStateAutomationEngineGovV2() {
|
|
1405
|
+
_augovPsV2.clear();
|
|
1406
|
+
_augovJsV2.clear();
|
|
1407
|
+
_augovMaxActive = 10;
|
|
1408
|
+
_augovMaxPending = 25;
|
|
1409
|
+
_augovIdleMs = 30 * 24 * 60 * 60 * 1000;
|
|
1410
|
+
_augovStuckMs = 60 * 1000;
|
|
1411
|
+
}
|
|
1412
|
+
export function registerAugovProfileV2({
|
|
1413
|
+
id,
|
|
1414
|
+
owner,
|
|
1415
|
+
connector,
|
|
1416
|
+
metadata,
|
|
1417
|
+
} = {}) {
|
|
1418
|
+
if (!id || !owner) throw new Error("id and owner required");
|
|
1419
|
+
if (_augovPsV2.has(id)) throw new Error(`augov profile ${id} already exists`);
|
|
1420
|
+
const now = Date.now();
|
|
1421
|
+
const p = {
|
|
1422
|
+
id,
|
|
1423
|
+
owner,
|
|
1424
|
+
connector: connector || "webhook",
|
|
1425
|
+
status: AUGOV_PROFILE_MATURITY_V2.PENDING,
|
|
1426
|
+
createdAt: now,
|
|
1427
|
+
updatedAt: now,
|
|
1428
|
+
lastTouchedAt: now,
|
|
1429
|
+
activatedAt: null,
|
|
1430
|
+
archivedAt: null,
|
|
1431
|
+
metadata: { ...(metadata || {}) },
|
|
1432
|
+
};
|
|
1433
|
+
_augovPsV2.set(id, p);
|
|
1434
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
1435
|
+
}
|
|
1436
|
+
export function activateAugovProfileV2(id) {
|
|
1437
|
+
const p = _augovPsV2.get(id);
|
|
1438
|
+
if (!p) throw new Error(`augov profile ${id} not found`);
|
|
1439
|
+
const isInitial = p.status === AUGOV_PROFILE_MATURITY_V2.PENDING;
|
|
1440
|
+
_augovCheckP(p.status, AUGOV_PROFILE_MATURITY_V2.ACTIVE);
|
|
1441
|
+
if (isInitial && _augovCountActive(p.owner) >= _augovMaxActive)
|
|
1442
|
+
throw new Error(`max active augov profiles for owner ${p.owner} reached`);
|
|
1443
|
+
const now = Date.now();
|
|
1444
|
+
p.status = AUGOV_PROFILE_MATURITY_V2.ACTIVE;
|
|
1445
|
+
p.updatedAt = now;
|
|
1446
|
+
p.lastTouchedAt = now;
|
|
1447
|
+
if (!p.activatedAt) p.activatedAt = now;
|
|
1448
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
1449
|
+
}
|
|
1450
|
+
export function pauseAugovProfileV2(id) {
|
|
1451
|
+
const p = _augovPsV2.get(id);
|
|
1452
|
+
if (!p) throw new Error(`augov profile ${id} not found`);
|
|
1453
|
+
_augovCheckP(p.status, AUGOV_PROFILE_MATURITY_V2.PAUSED);
|
|
1454
|
+
p.status = AUGOV_PROFILE_MATURITY_V2.PAUSED;
|
|
1455
|
+
p.updatedAt = Date.now();
|
|
1456
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
1457
|
+
}
|
|
1458
|
+
export function archiveAugovProfileV2(id) {
|
|
1459
|
+
const p = _augovPsV2.get(id);
|
|
1460
|
+
if (!p) throw new Error(`augov profile ${id} not found`);
|
|
1461
|
+
_augovCheckP(p.status, AUGOV_PROFILE_MATURITY_V2.ARCHIVED);
|
|
1462
|
+
const now = Date.now();
|
|
1463
|
+
p.status = AUGOV_PROFILE_MATURITY_V2.ARCHIVED;
|
|
1464
|
+
p.updatedAt = now;
|
|
1465
|
+
if (!p.archivedAt) p.archivedAt = now;
|
|
1466
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
1467
|
+
}
|
|
1468
|
+
export function touchAugovProfileV2(id) {
|
|
1469
|
+
const p = _augovPsV2.get(id);
|
|
1470
|
+
if (!p) throw new Error(`augov profile ${id} not found`);
|
|
1471
|
+
if (_augovPTerminal.has(p.status))
|
|
1472
|
+
throw new Error(`cannot touch terminal augov profile ${id}`);
|
|
1473
|
+
const now = Date.now();
|
|
1474
|
+
p.lastTouchedAt = now;
|
|
1475
|
+
p.updatedAt = now;
|
|
1476
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
1477
|
+
}
|
|
1478
|
+
export function getAugovProfileV2(id) {
|
|
1479
|
+
const p = _augovPsV2.get(id);
|
|
1480
|
+
if (!p) return null;
|
|
1481
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
1482
|
+
}
|
|
1483
|
+
export function listAugovProfilesV2() {
|
|
1484
|
+
return [..._augovPsV2.values()].map((p) => ({
|
|
1485
|
+
...p,
|
|
1486
|
+
metadata: { ...p.metadata },
|
|
1487
|
+
}));
|
|
1488
|
+
}
|
|
1489
|
+
export function createAugovFlowV2({ id, profileId, trigger, metadata } = {}) {
|
|
1490
|
+
if (!id || !profileId) throw new Error("id and profileId required");
|
|
1491
|
+
if (_augovJsV2.has(id)) throw new Error(`augov flow ${id} already exists`);
|
|
1492
|
+
if (!_augovPsV2.has(profileId))
|
|
1493
|
+
throw new Error(`augov profile ${profileId} not found`);
|
|
1494
|
+
if (_augovCountPending(profileId) >= _augovMaxPending)
|
|
1495
|
+
throw new Error(`max pending augov flows for profile ${profileId} reached`);
|
|
1496
|
+
const now = Date.now();
|
|
1497
|
+
const j = {
|
|
1498
|
+
id,
|
|
1499
|
+
profileId,
|
|
1500
|
+
trigger: trigger || "",
|
|
1501
|
+
status: AUGOV_FLOW_LIFECYCLE_V2.QUEUED,
|
|
1502
|
+
createdAt: now,
|
|
1503
|
+
updatedAt: now,
|
|
1504
|
+
startedAt: null,
|
|
1505
|
+
settledAt: null,
|
|
1506
|
+
metadata: { ...(metadata || {}) },
|
|
1507
|
+
};
|
|
1508
|
+
_augovJsV2.set(id, j);
|
|
1509
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
1510
|
+
}
|
|
1511
|
+
export function runningAugovFlowV2(id) {
|
|
1512
|
+
const j = _augovJsV2.get(id);
|
|
1513
|
+
if (!j) throw new Error(`augov flow ${id} not found`);
|
|
1514
|
+
_augovCheckJ(j.status, AUGOV_FLOW_LIFECYCLE_V2.RUNNING);
|
|
1515
|
+
const now = Date.now();
|
|
1516
|
+
j.status = AUGOV_FLOW_LIFECYCLE_V2.RUNNING;
|
|
1517
|
+
j.updatedAt = now;
|
|
1518
|
+
if (!j.startedAt) j.startedAt = now;
|
|
1519
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
1520
|
+
}
|
|
1521
|
+
export function completeFlowAugovV2(id) {
|
|
1522
|
+
const j = _augovJsV2.get(id);
|
|
1523
|
+
if (!j) throw new Error(`augov flow ${id} not found`);
|
|
1524
|
+
_augovCheckJ(j.status, AUGOV_FLOW_LIFECYCLE_V2.COMPLETED);
|
|
1525
|
+
const now = Date.now();
|
|
1526
|
+
j.status = AUGOV_FLOW_LIFECYCLE_V2.COMPLETED;
|
|
1527
|
+
j.updatedAt = now;
|
|
1528
|
+
if (!j.settledAt) j.settledAt = now;
|
|
1529
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
1530
|
+
}
|
|
1531
|
+
export function failAugovFlowV2(id, reason) {
|
|
1532
|
+
const j = _augovJsV2.get(id);
|
|
1533
|
+
if (!j) throw new Error(`augov flow ${id} not found`);
|
|
1534
|
+
_augovCheckJ(j.status, AUGOV_FLOW_LIFECYCLE_V2.FAILED);
|
|
1535
|
+
const now = Date.now();
|
|
1536
|
+
j.status = AUGOV_FLOW_LIFECYCLE_V2.FAILED;
|
|
1537
|
+
j.updatedAt = now;
|
|
1538
|
+
if (!j.settledAt) j.settledAt = now;
|
|
1539
|
+
if (reason) j.metadata.failReason = String(reason);
|
|
1540
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
1541
|
+
}
|
|
1542
|
+
export function cancelAugovFlowV2(id, reason) {
|
|
1543
|
+
const j = _augovJsV2.get(id);
|
|
1544
|
+
if (!j) throw new Error(`augov flow ${id} not found`);
|
|
1545
|
+
_augovCheckJ(j.status, AUGOV_FLOW_LIFECYCLE_V2.CANCELLED);
|
|
1546
|
+
const now = Date.now();
|
|
1547
|
+
j.status = AUGOV_FLOW_LIFECYCLE_V2.CANCELLED;
|
|
1548
|
+
j.updatedAt = now;
|
|
1549
|
+
if (!j.settledAt) j.settledAt = now;
|
|
1550
|
+
if (reason) j.metadata.cancelReason = String(reason);
|
|
1551
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
1552
|
+
}
|
|
1553
|
+
export function getAugovFlowV2(id) {
|
|
1554
|
+
const j = _augovJsV2.get(id);
|
|
1555
|
+
if (!j) return null;
|
|
1556
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
1557
|
+
}
|
|
1558
|
+
export function listAugovFlowsV2() {
|
|
1559
|
+
return [..._augovJsV2.values()].map((j) => ({
|
|
1560
|
+
...j,
|
|
1561
|
+
metadata: { ...j.metadata },
|
|
1562
|
+
}));
|
|
1563
|
+
}
|
|
1564
|
+
export function autoPauseIdleAugovProfilesV2({ now } = {}) {
|
|
1565
|
+
const t = now ?? Date.now();
|
|
1566
|
+
const flipped = [];
|
|
1567
|
+
for (const p of _augovPsV2.values())
|
|
1568
|
+
if (
|
|
1569
|
+
p.status === AUGOV_PROFILE_MATURITY_V2.ACTIVE &&
|
|
1570
|
+
t - p.lastTouchedAt >= _augovIdleMs
|
|
1571
|
+
) {
|
|
1572
|
+
p.status = AUGOV_PROFILE_MATURITY_V2.PAUSED;
|
|
1573
|
+
p.updatedAt = t;
|
|
1574
|
+
flipped.push(p.id);
|
|
1575
|
+
}
|
|
1576
|
+
return { flipped, count: flipped.length };
|
|
1577
|
+
}
|
|
1578
|
+
export function autoFailStuckAugovFlowsV2({ now } = {}) {
|
|
1579
|
+
const t = now ?? Date.now();
|
|
1580
|
+
const flipped = [];
|
|
1581
|
+
for (const j of _augovJsV2.values())
|
|
1582
|
+
if (
|
|
1583
|
+
j.status === AUGOV_FLOW_LIFECYCLE_V2.RUNNING &&
|
|
1584
|
+
j.startedAt != null &&
|
|
1585
|
+
t - j.startedAt >= _augovStuckMs
|
|
1586
|
+
) {
|
|
1587
|
+
j.status = AUGOV_FLOW_LIFECYCLE_V2.FAILED;
|
|
1588
|
+
j.updatedAt = t;
|
|
1589
|
+
if (!j.settledAt) j.settledAt = t;
|
|
1590
|
+
j.metadata.failReason = "auto-fail-stuck";
|
|
1591
|
+
flipped.push(j.id);
|
|
1592
|
+
}
|
|
1593
|
+
return { flipped, count: flipped.length };
|
|
1594
|
+
}
|
|
1595
|
+
export function getAutomationEngineGovStatsV2() {
|
|
1596
|
+
const profilesByStatus = {};
|
|
1597
|
+
for (const v of Object.values(AUGOV_PROFILE_MATURITY_V2))
|
|
1598
|
+
profilesByStatus[v] = 0;
|
|
1599
|
+
for (const p of _augovPsV2.values()) profilesByStatus[p.status]++;
|
|
1600
|
+
const flowsByStatus = {};
|
|
1601
|
+
for (const v of Object.values(AUGOV_FLOW_LIFECYCLE_V2)) flowsByStatus[v] = 0;
|
|
1602
|
+
for (const j of _augovJsV2.values()) flowsByStatus[j.status]++;
|
|
1603
|
+
return {
|
|
1604
|
+
totalAugovProfilesV2: _augovPsV2.size,
|
|
1605
|
+
totalAugovFlowsV2: _augovJsV2.size,
|
|
1606
|
+
maxActiveAugovProfilesPerOwner: _augovMaxActive,
|
|
1607
|
+
maxPendingAugovFlowsPerProfile: _augovMaxPending,
|
|
1608
|
+
augovProfileIdleMs: _augovIdleMs,
|
|
1609
|
+
augovFlowStuckMs: _augovStuckMs,
|
|
1610
|
+
profilesByStatus,
|
|
1611
|
+
flowsByStatus,
|
|
1612
|
+
};
|
|
1613
|
+
}
|