chainlesschain 0.143.0 → 0.145.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/a2a.js +196 -28
- package/src/commands/activitypub.js +157 -27
- package/src/commands/agent.js +587 -103
- package/src/commands/audit.js +206 -0
- package/src/commands/bi.js +152 -27
- package/src/commands/bm25.js +111 -27
- package/src/commands/browse.js +190 -29
- package/src/commands/ccron.js +128 -28
- package/src/commands/chat.js +207 -0
- package/src/commands/compliance.js +414 -34
- package/src/commands/compt.js +127 -29
- package/src/commands/consol.js +8 -2
- package/src/commands/cowork.js +580 -34
- package/src/commands/crosschain.js +182 -28
- package/src/commands/dao.js +182 -28
- package/src/commands/dlp.js +172 -27
- package/src/commands/economy.js +205 -50
- package/src/commands/evolution.js +203 -50
- package/src/commands/evomap.js +182 -27
- package/src/commands/fflag.js +74 -22
- package/src/commands/git.js +177 -37
- package/src/commands/hardening.js +209 -0
- package/src/commands/hmemory.js +204 -50
- package/src/commands/incentive.js +209 -0
- package/src/commands/inference.js +170 -34
- package/src/commands/itbudget.js +149 -33
- package/src/commands/kg.js +206 -0
- package/src/commands/lowcode.js +195 -38
- package/src/commands/marketplace.js +206 -0
- package/src/commands/matrix.js +179 -27
- package/src/commands/mcpscaf.js +145 -33
- package/src/commands/meminj.js +145 -33
- package/src/commands/nostr.js +178 -27
- package/src/commands/orchestrate.js +217 -0
- package/src/commands/orchgov.js +144 -33
- package/src/commands/pdfp.js +109 -27
- package/src/commands/perf.js +169 -32
- package/src/commands/perm.js +144 -33
- package/src/commands/pipeline.js +207 -52
- package/src/commands/planmode.js +141 -32
- package/src/commands/privacy.js +203 -0
- package/src/commands/promcomp.js +111 -27
- package/src/commands/recommend.js +177 -34
- package/src/commands/reputation.js +208 -0
- package/src/commands/sandbox.js +206 -0
- package/src/commands/seshhook.js +145 -33
- package/src/commands/seshsearch.js +141 -33
- package/src/commands/seshtail.js +144 -33
- package/src/commands/seshu.js +152 -33
- package/src/commands/sganal.js +123 -29
- package/src/commands/siem.js +201 -34
- package/src/commands/sla.js +212 -0
- package/src/commands/slotfill.js +146 -33
- package/src/commands/social.js +157 -32
- package/src/commands/stress.js +206 -0
- package/src/commands/svccont.js +145 -33
- package/src/commands/terraform.js +206 -0
- package/src/commands/tms.js +171 -33
- package/src/commands/topiccls.js +146 -33
- package/src/commands/uprof.js +141 -32
- package/src/commands/vcheck.js +122 -28
- package/src/commands/webfetch.js +141 -32
- package/src/commands/zkp.js +184 -28
- package/src/index.js +40 -0
- package/src/lib/a2a-protocol.js +319 -51
- package/src/lib/activitypub-bridge.js +288 -50
- package/src/lib/agent-economy.js +304 -51
- package/src/lib/app-builder.js +279 -46
- package/src/lib/audit-logger.js +321 -0
- package/src/lib/autonomous-agent.js +284 -48
- package/src/lib/bi-engine.js +283 -49
- package/src/lib/bm25-search.js +301 -49
- package/src/lib/browser-automation.js +296 -49
- package/src/lib/chat-core.js +336 -0
- package/src/lib/claude-code-bridge.js +341 -0
- package/src/lib/compliance-framework-reporter.js +305 -51
- package/src/lib/compliance-manager.js +330 -0
- package/src/lib/compression-telemetry.js +301 -49
- package/src/lib/content-recommender.js +317 -52
- package/src/lib/cowork-cron.js +298 -49
- package/src/lib/cowork-learning.js +333 -0
- package/src/lib/cowork-task-runner.js +308 -51
- package/src/lib/cowork-workflow.js +327 -0
- package/src/lib/cross-chain.js +311 -51
- package/src/lib/dao-governance.js +280 -46
- package/src/lib/dlp-engine.js +287 -49
- package/src/lib/evolution-system.js +278 -47
- package/src/lib/evomap-manager.js +280 -46
- package/src/lib/execution-backend.js +294 -48
- package/src/lib/feature-flags.js +294 -49
- package/src/lib/git-integration.js +285 -47
- package/src/lib/hardening-manager.js +341 -0
- package/src/lib/hierarchical-memory.js +284 -48
- package/src/lib/inference-network.js +308 -51
- package/src/lib/iteration-budget.js +302 -50
- package/src/lib/knowledge-graph.js +333 -0
- package/src/lib/matrix-bridge.js +281 -47
- package/src/lib/mcp-scaffold.js +318 -54
- package/src/lib/memory-injection.js +288 -49
- package/src/lib/nostr-bridge.js +286 -49
- package/src/lib/orchestrator.js +293 -48
- package/src/lib/pdf-parser.js +298 -49
- package/src/lib/perf-tuning.js +309 -50
- package/src/lib/permission-engine.js +287 -49
- package/src/lib/pipeline-orchestrator.js +289 -49
- package/src/lib/plan-mode.js +298 -51
- package/src/lib/privacy-computing.js +335 -0
- package/src/lib/reputation-optimizer.js +340 -0
- package/src/lib/sandbox-v2.js +327 -0
- package/src/lib/service-container.js +313 -52
- package/src/lib/session-consolidator.js +296 -49
- package/src/lib/session-hooks.js +312 -53
- package/src/lib/session-search.js +304 -51
- package/src/lib/session-tail.js +288 -49
- package/src/lib/session-usage.js +298 -52
- package/src/lib/siem-exporter.js +298 -51
- package/src/lib/skill-marketplace.js +345 -0
- package/src/lib/sla-manager.js +341 -0
- package/src/lib/slot-filler.js +303 -51
- package/src/lib/social-graph-analytics.js +295 -49
- package/src/lib/social-graph.js +272 -49
- package/src/lib/stress-tester.js +342 -0
- package/src/lib/sub-agent-registry.js +302 -53
- package/src/lib/task-model-selector.js +302 -50
- package/src/lib/terraform-manager.js +333 -0
- package/src/lib/todo-manager.js +281 -47
- package/src/lib/token-incentive.js +341 -0
- package/src/lib/topic-classifier.js +297 -49
- package/src/lib/user-profile.js +294 -50
- package/src/lib/version-checker.js +304 -50
- package/src/lib/web-fetch.js +292 -51
- package/src/lib/zkp-engine.js +286 -49
|
@@ -4,83 +4,335 @@ export {
|
|
|
4
4
|
resetCompressionTelemetry,
|
|
5
5
|
} from "../harness/compression-telemetry.js";
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
// =====================================================================
|
|
9
8
|
// Compression Telemetry V2 governance overlay
|
|
10
9
|
// =====================================================================
|
|
11
|
-
export const COMPT_PROFILE_MATURITY_V2 = Object.freeze({
|
|
12
|
-
|
|
10
|
+
export const COMPT_PROFILE_MATURITY_V2 = Object.freeze({
|
|
11
|
+
PENDING: "pending",
|
|
12
|
+
ACTIVE: "active",
|
|
13
|
+
STALE: "stale",
|
|
14
|
+
ARCHIVED: "archived",
|
|
15
|
+
});
|
|
16
|
+
export const COMPT_SAMPLE_LIFECYCLE_V2 = Object.freeze({
|
|
17
|
+
QUEUED: "queued",
|
|
18
|
+
RECORDING: "recording",
|
|
19
|
+
RECORDED: "recorded",
|
|
20
|
+
FAILED: "failed",
|
|
21
|
+
CANCELLED: "cancelled",
|
|
22
|
+
});
|
|
13
23
|
const _comptPTrans = new Map([
|
|
14
|
-
[
|
|
15
|
-
|
|
16
|
-
|
|
24
|
+
[
|
|
25
|
+
COMPT_PROFILE_MATURITY_V2.PENDING,
|
|
26
|
+
new Set([
|
|
27
|
+
COMPT_PROFILE_MATURITY_V2.ACTIVE,
|
|
28
|
+
COMPT_PROFILE_MATURITY_V2.ARCHIVED,
|
|
29
|
+
]),
|
|
30
|
+
],
|
|
31
|
+
[
|
|
32
|
+
COMPT_PROFILE_MATURITY_V2.ACTIVE,
|
|
33
|
+
new Set([
|
|
34
|
+
COMPT_PROFILE_MATURITY_V2.STALE,
|
|
35
|
+
COMPT_PROFILE_MATURITY_V2.ARCHIVED,
|
|
36
|
+
]),
|
|
37
|
+
],
|
|
38
|
+
[
|
|
39
|
+
COMPT_PROFILE_MATURITY_V2.STALE,
|
|
40
|
+
new Set([
|
|
41
|
+
COMPT_PROFILE_MATURITY_V2.ACTIVE,
|
|
42
|
+
COMPT_PROFILE_MATURITY_V2.ARCHIVED,
|
|
43
|
+
]),
|
|
44
|
+
],
|
|
17
45
|
[COMPT_PROFILE_MATURITY_V2.ARCHIVED, new Set()],
|
|
18
46
|
]);
|
|
19
47
|
const _comptPTerminal = new Set([COMPT_PROFILE_MATURITY_V2.ARCHIVED]);
|
|
20
48
|
const _comptJTrans = new Map([
|
|
21
|
-
[
|
|
22
|
-
|
|
49
|
+
[
|
|
50
|
+
COMPT_SAMPLE_LIFECYCLE_V2.QUEUED,
|
|
51
|
+
new Set([
|
|
52
|
+
COMPT_SAMPLE_LIFECYCLE_V2.RECORDING,
|
|
53
|
+
COMPT_SAMPLE_LIFECYCLE_V2.CANCELLED,
|
|
54
|
+
]),
|
|
55
|
+
],
|
|
56
|
+
[
|
|
57
|
+
COMPT_SAMPLE_LIFECYCLE_V2.RECORDING,
|
|
58
|
+
new Set([
|
|
59
|
+
COMPT_SAMPLE_LIFECYCLE_V2.RECORDED,
|
|
60
|
+
COMPT_SAMPLE_LIFECYCLE_V2.FAILED,
|
|
61
|
+
COMPT_SAMPLE_LIFECYCLE_V2.CANCELLED,
|
|
62
|
+
]),
|
|
63
|
+
],
|
|
23
64
|
[COMPT_SAMPLE_LIFECYCLE_V2.RECORDED, new Set()],
|
|
24
65
|
[COMPT_SAMPLE_LIFECYCLE_V2.FAILED, new Set()],
|
|
25
66
|
[COMPT_SAMPLE_LIFECYCLE_V2.CANCELLED, new Set()],
|
|
26
67
|
]);
|
|
27
68
|
const _comptPsV2 = new Map();
|
|
28
69
|
const _comptJsV2 = new Map();
|
|
29
|
-
let _comptMaxActive = 10,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
70
|
+
let _comptMaxActive = 10,
|
|
71
|
+
_comptMaxPending = 30,
|
|
72
|
+
_comptIdleMs = 30 * 24 * 60 * 60 * 1000,
|
|
73
|
+
_comptStuckMs = 30 * 1000;
|
|
74
|
+
function _comptPos(n, label) {
|
|
75
|
+
const v = Math.floor(Number(n));
|
|
76
|
+
if (!Number.isFinite(v) || v <= 0)
|
|
77
|
+
throw new Error(`${label} must be positive integer`);
|
|
78
|
+
return v;
|
|
79
|
+
}
|
|
80
|
+
function _comptCheckP(from, to) {
|
|
81
|
+
const a = _comptPTrans.get(from);
|
|
82
|
+
if (!a || !a.has(to))
|
|
83
|
+
throw new Error(`invalid compt profile transition ${from} → ${to}`);
|
|
84
|
+
}
|
|
85
|
+
function _comptCheckJ(from, to) {
|
|
86
|
+
const a = _comptJTrans.get(from);
|
|
87
|
+
if (!a || !a.has(to))
|
|
88
|
+
throw new Error(`invalid compt sample transition ${from} → ${to}`);
|
|
89
|
+
}
|
|
90
|
+
function _comptCountActive(owner) {
|
|
91
|
+
let c = 0;
|
|
92
|
+
for (const p of _comptPsV2.values())
|
|
93
|
+
if (p.owner === owner && p.status === COMPT_PROFILE_MATURITY_V2.ACTIVE) c++;
|
|
94
|
+
return c;
|
|
95
|
+
}
|
|
96
|
+
function _comptCountPending(profileId) {
|
|
97
|
+
let c = 0;
|
|
98
|
+
for (const j of _comptJsV2.values())
|
|
99
|
+
if (
|
|
100
|
+
j.profileId === profileId &&
|
|
101
|
+
(j.status === COMPT_SAMPLE_LIFECYCLE_V2.QUEUED ||
|
|
102
|
+
j.status === COMPT_SAMPLE_LIFECYCLE_V2.RECORDING)
|
|
103
|
+
)
|
|
104
|
+
c++;
|
|
105
|
+
return c;
|
|
106
|
+
}
|
|
107
|
+
export function setMaxActiveComptProfilesPerOwnerV2(n) {
|
|
108
|
+
_comptMaxActive = _comptPos(n, "maxActiveComptProfilesPerOwner");
|
|
109
|
+
}
|
|
110
|
+
export function getMaxActiveComptProfilesPerOwnerV2() {
|
|
111
|
+
return _comptMaxActive;
|
|
112
|
+
}
|
|
113
|
+
export function setMaxPendingComptSamplesPerProfileV2(n) {
|
|
114
|
+
_comptMaxPending = _comptPos(n, "maxPendingComptSamplesPerProfile");
|
|
115
|
+
}
|
|
116
|
+
export function getMaxPendingComptSamplesPerProfileV2() {
|
|
117
|
+
return _comptMaxPending;
|
|
118
|
+
}
|
|
119
|
+
export function setComptProfileIdleMsV2(n) {
|
|
120
|
+
_comptIdleMs = _comptPos(n, "comptProfileIdleMs");
|
|
121
|
+
}
|
|
122
|
+
export function getComptProfileIdleMsV2() {
|
|
123
|
+
return _comptIdleMs;
|
|
124
|
+
}
|
|
125
|
+
export function setComptSampleStuckMsV2(n) {
|
|
126
|
+
_comptStuckMs = _comptPos(n, "comptSampleStuckMs");
|
|
127
|
+
}
|
|
128
|
+
export function getComptSampleStuckMsV2() {
|
|
129
|
+
return _comptStuckMs;
|
|
130
|
+
}
|
|
131
|
+
export function _resetStateCompressionTelemetryV2() {
|
|
132
|
+
_comptPsV2.clear();
|
|
133
|
+
_comptJsV2.clear();
|
|
134
|
+
_comptMaxActive = 10;
|
|
135
|
+
_comptMaxPending = 30;
|
|
136
|
+
_comptIdleMs = 30 * 24 * 60 * 60 * 1000;
|
|
137
|
+
_comptStuckMs = 30 * 1000;
|
|
138
|
+
}
|
|
44
139
|
export function registerComptProfileV2({ id, owner, kind, metadata } = {}) {
|
|
45
140
|
if (!id || !owner) throw new Error("id and owner required");
|
|
46
141
|
if (_comptPsV2.has(id)) throw new Error(`compt profile ${id} already exists`);
|
|
47
142
|
const now = Date.now();
|
|
48
|
-
const p = {
|
|
49
|
-
|
|
143
|
+
const p = {
|
|
144
|
+
id,
|
|
145
|
+
owner,
|
|
146
|
+
kind: kind || "default",
|
|
147
|
+
status: COMPT_PROFILE_MATURITY_V2.PENDING,
|
|
148
|
+
createdAt: now,
|
|
149
|
+
updatedAt: now,
|
|
150
|
+
lastTouchedAt: now,
|
|
151
|
+
activatedAt: null,
|
|
152
|
+
archivedAt: null,
|
|
153
|
+
metadata: { ...(metadata || {}) },
|
|
154
|
+
};
|
|
155
|
+
_comptPsV2.set(id, p);
|
|
156
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
50
157
|
}
|
|
51
158
|
export function activateComptProfileV2(id) {
|
|
52
|
-
const p = _comptPsV2.get(id);
|
|
159
|
+
const p = _comptPsV2.get(id);
|
|
160
|
+
if (!p) throw new Error(`compt profile ${id} not found`);
|
|
53
161
|
const isInitial = p.status === COMPT_PROFILE_MATURITY_V2.PENDING;
|
|
54
162
|
_comptCheckP(p.status, COMPT_PROFILE_MATURITY_V2.ACTIVE);
|
|
55
|
-
if (isInitial && _comptCountActive(p.owner) >= _comptMaxActive)
|
|
56
|
-
|
|
163
|
+
if (isInitial && _comptCountActive(p.owner) >= _comptMaxActive)
|
|
164
|
+
throw new Error(`max active compt profiles for owner ${p.owner} reached`);
|
|
165
|
+
const now = Date.now();
|
|
166
|
+
p.status = COMPT_PROFILE_MATURITY_V2.ACTIVE;
|
|
167
|
+
p.updatedAt = now;
|
|
168
|
+
p.lastTouchedAt = now;
|
|
57
169
|
if (!p.activatedAt) p.activatedAt = now;
|
|
58
170
|
return { ...p, metadata: { ...p.metadata } };
|
|
59
171
|
}
|
|
60
|
-
export function staleComptProfileV2(id) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
172
|
+
export function staleComptProfileV2(id) {
|
|
173
|
+
const p = _comptPsV2.get(id);
|
|
174
|
+
if (!p) throw new Error(`compt profile ${id} not found`);
|
|
175
|
+
_comptCheckP(p.status, COMPT_PROFILE_MATURITY_V2.STALE);
|
|
176
|
+
p.status = COMPT_PROFILE_MATURITY_V2.STALE;
|
|
177
|
+
p.updatedAt = Date.now();
|
|
178
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
179
|
+
}
|
|
180
|
+
export function archiveComptProfileV2(id) {
|
|
181
|
+
const p = _comptPsV2.get(id);
|
|
182
|
+
if (!p) throw new Error(`compt profile ${id} not found`);
|
|
183
|
+
_comptCheckP(p.status, COMPT_PROFILE_MATURITY_V2.ARCHIVED);
|
|
184
|
+
const now = Date.now();
|
|
185
|
+
p.status = COMPT_PROFILE_MATURITY_V2.ARCHIVED;
|
|
186
|
+
p.updatedAt = now;
|
|
187
|
+
if (!p.archivedAt) p.archivedAt = now;
|
|
188
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
189
|
+
}
|
|
190
|
+
export function touchComptProfileV2(id) {
|
|
191
|
+
const p = _comptPsV2.get(id);
|
|
192
|
+
if (!p) throw new Error(`compt profile ${id} not found`);
|
|
193
|
+
if (_comptPTerminal.has(p.status))
|
|
194
|
+
throw new Error(`cannot touch terminal compt profile ${id}`);
|
|
195
|
+
const now = Date.now();
|
|
196
|
+
p.lastTouchedAt = now;
|
|
197
|
+
p.updatedAt = now;
|
|
198
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
199
|
+
}
|
|
200
|
+
export function getComptProfileV2(id) {
|
|
201
|
+
const p = _comptPsV2.get(id);
|
|
202
|
+
if (!p) return null;
|
|
203
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
204
|
+
}
|
|
205
|
+
export function listComptProfilesV2() {
|
|
206
|
+
return [..._comptPsV2.values()].map((p) => ({
|
|
207
|
+
...p,
|
|
208
|
+
metadata: { ...p.metadata },
|
|
209
|
+
}));
|
|
210
|
+
}
|
|
65
211
|
export function createComptSampleV2({ id, profileId, metric, metadata } = {}) {
|
|
66
212
|
if (!id || !profileId) throw new Error("id and profileId required");
|
|
67
213
|
if (_comptJsV2.has(id)) throw new Error(`compt sample ${id} already exists`);
|
|
68
|
-
if (!_comptPsV2.has(profileId))
|
|
69
|
-
|
|
214
|
+
if (!_comptPsV2.has(profileId))
|
|
215
|
+
throw new Error(`compt profile ${profileId} not found`);
|
|
216
|
+
if (_comptCountPending(profileId) >= _comptMaxPending)
|
|
217
|
+
throw new Error(
|
|
218
|
+
`max pending compt samples for profile ${profileId} reached`,
|
|
219
|
+
);
|
|
220
|
+
const now = Date.now();
|
|
221
|
+
const j = {
|
|
222
|
+
id,
|
|
223
|
+
profileId,
|
|
224
|
+
metric: metric || "",
|
|
225
|
+
status: COMPT_SAMPLE_LIFECYCLE_V2.QUEUED,
|
|
226
|
+
createdAt: now,
|
|
227
|
+
updatedAt: now,
|
|
228
|
+
startedAt: null,
|
|
229
|
+
settledAt: null,
|
|
230
|
+
metadata: { ...(metadata || {}) },
|
|
231
|
+
};
|
|
232
|
+
_comptJsV2.set(id, j);
|
|
233
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
234
|
+
}
|
|
235
|
+
export function recordingComptSampleV2(id) {
|
|
236
|
+
const j = _comptJsV2.get(id);
|
|
237
|
+
if (!j) throw new Error(`compt sample ${id} not found`);
|
|
238
|
+
_comptCheckJ(j.status, COMPT_SAMPLE_LIFECYCLE_V2.RECORDING);
|
|
239
|
+
const now = Date.now();
|
|
240
|
+
j.status = COMPT_SAMPLE_LIFECYCLE_V2.RECORDING;
|
|
241
|
+
j.updatedAt = now;
|
|
242
|
+
if (!j.startedAt) j.startedAt = now;
|
|
243
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
244
|
+
}
|
|
245
|
+
export function recordComptSampleV2(id) {
|
|
246
|
+
const j = _comptJsV2.get(id);
|
|
247
|
+
if (!j) throw new Error(`compt sample ${id} not found`);
|
|
248
|
+
_comptCheckJ(j.status, COMPT_SAMPLE_LIFECYCLE_V2.RECORDED);
|
|
249
|
+
const now = Date.now();
|
|
250
|
+
j.status = COMPT_SAMPLE_LIFECYCLE_V2.RECORDED;
|
|
251
|
+
j.updatedAt = now;
|
|
252
|
+
if (!j.settledAt) j.settledAt = now;
|
|
253
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
254
|
+
}
|
|
255
|
+
export function failComptSampleV2(id, reason) {
|
|
256
|
+
const j = _comptJsV2.get(id);
|
|
257
|
+
if (!j) throw new Error(`compt sample ${id} not found`);
|
|
258
|
+
_comptCheckJ(j.status, COMPT_SAMPLE_LIFECYCLE_V2.FAILED);
|
|
259
|
+
const now = Date.now();
|
|
260
|
+
j.status = COMPT_SAMPLE_LIFECYCLE_V2.FAILED;
|
|
261
|
+
j.updatedAt = now;
|
|
262
|
+
if (!j.settledAt) j.settledAt = now;
|
|
263
|
+
if (reason) j.metadata.failReason = String(reason);
|
|
264
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
265
|
+
}
|
|
266
|
+
export function cancelComptSampleV2(id, reason) {
|
|
267
|
+
const j = _comptJsV2.get(id);
|
|
268
|
+
if (!j) throw new Error(`compt sample ${id} not found`);
|
|
269
|
+
_comptCheckJ(j.status, COMPT_SAMPLE_LIFECYCLE_V2.CANCELLED);
|
|
70
270
|
const now = Date.now();
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
export function
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
271
|
+
j.status = COMPT_SAMPLE_LIFECYCLE_V2.CANCELLED;
|
|
272
|
+
j.updatedAt = now;
|
|
273
|
+
if (!j.settledAt) j.settledAt = now;
|
|
274
|
+
if (reason) j.metadata.cancelReason = String(reason);
|
|
275
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
276
|
+
}
|
|
277
|
+
export function getComptSampleV2(id) {
|
|
278
|
+
const j = _comptJsV2.get(id);
|
|
279
|
+
if (!j) return null;
|
|
280
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
281
|
+
}
|
|
282
|
+
export function listComptSamplesV2() {
|
|
283
|
+
return [..._comptJsV2.values()].map((j) => ({
|
|
284
|
+
...j,
|
|
285
|
+
metadata: { ...j.metadata },
|
|
286
|
+
}));
|
|
287
|
+
}
|
|
288
|
+
export function autoStaleIdleComptProfilesV2({ now } = {}) {
|
|
289
|
+
const t = now ?? Date.now();
|
|
290
|
+
const flipped = [];
|
|
291
|
+
for (const p of _comptPsV2.values())
|
|
292
|
+
if (
|
|
293
|
+
p.status === COMPT_PROFILE_MATURITY_V2.ACTIVE &&
|
|
294
|
+
t - p.lastTouchedAt >= _comptIdleMs
|
|
295
|
+
) {
|
|
296
|
+
p.status = COMPT_PROFILE_MATURITY_V2.STALE;
|
|
297
|
+
p.updatedAt = t;
|
|
298
|
+
flipped.push(p.id);
|
|
299
|
+
}
|
|
300
|
+
return { flipped, count: flipped.length };
|
|
301
|
+
}
|
|
302
|
+
export function autoFailStuckComptSamplesV2({ now } = {}) {
|
|
303
|
+
const t = now ?? Date.now();
|
|
304
|
+
const flipped = [];
|
|
305
|
+
for (const j of _comptJsV2.values())
|
|
306
|
+
if (
|
|
307
|
+
j.status === COMPT_SAMPLE_LIFECYCLE_V2.RECORDING &&
|
|
308
|
+
j.startedAt != null &&
|
|
309
|
+
t - j.startedAt >= _comptStuckMs
|
|
310
|
+
) {
|
|
311
|
+
j.status = COMPT_SAMPLE_LIFECYCLE_V2.FAILED;
|
|
312
|
+
j.updatedAt = t;
|
|
313
|
+
if (!j.settledAt) j.settledAt = t;
|
|
314
|
+
j.metadata.failReason = "auto-fail-stuck";
|
|
315
|
+
flipped.push(j.id);
|
|
316
|
+
}
|
|
317
|
+
return { flipped, count: flipped.length };
|
|
318
|
+
}
|
|
82
319
|
export function getCompressionTelemetryGovStatsV2() {
|
|
83
|
-
const profilesByStatus = {};
|
|
84
|
-
|
|
85
|
-
|
|
320
|
+
const profilesByStatus = {};
|
|
321
|
+
for (const v of Object.values(COMPT_PROFILE_MATURITY_V2))
|
|
322
|
+
profilesByStatus[v] = 0;
|
|
323
|
+
for (const p of _comptPsV2.values()) profilesByStatus[p.status]++;
|
|
324
|
+
const samplesByStatus = {};
|
|
325
|
+
for (const v of Object.values(COMPT_SAMPLE_LIFECYCLE_V2))
|
|
326
|
+
samplesByStatus[v] = 0;
|
|
327
|
+
for (const j of _comptJsV2.values()) samplesByStatus[j.status]++;
|
|
328
|
+
return {
|
|
329
|
+
totalComptProfilesV2: _comptPsV2.size,
|
|
330
|
+
totalComptSamplesV2: _comptJsV2.size,
|
|
331
|
+
maxActiveComptProfilesPerOwner: _comptMaxActive,
|
|
332
|
+
maxPendingComptSamplesPerProfile: _comptMaxPending,
|
|
333
|
+
comptProfileIdleMs: _comptIdleMs,
|
|
334
|
+
comptSampleStuckMs: _comptStuckMs,
|
|
335
|
+
profilesByStatus,
|
|
336
|
+
samplesByStatus,
|
|
337
|
+
};
|
|
86
338
|
}
|