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
package/src/lib/stress-tester.js
CHANGED
|
@@ -711,3 +711,345 @@ export function getStressStatsV2() {
|
|
|
711
711
|
},
|
|
712
712
|
};
|
|
713
713
|
}
|
|
714
|
+
|
|
715
|
+
// =====================================================================
|
|
716
|
+
// stress-tester V2 governance overlay (iter16)
|
|
717
|
+
// =====================================================================
|
|
718
|
+
export const STRGOV_PROFILE_MATURITY_V2 = Object.freeze({
|
|
719
|
+
PENDING: "pending",
|
|
720
|
+
ACTIVE: "active",
|
|
721
|
+
STALE: "stale",
|
|
722
|
+
ARCHIVED: "archived",
|
|
723
|
+
});
|
|
724
|
+
export const STRGOV_RUN_LIFECYCLE_V2 = Object.freeze({
|
|
725
|
+
QUEUED: "queued",
|
|
726
|
+
RUNNING: "running",
|
|
727
|
+
COMPLETED: "completed",
|
|
728
|
+
FAILED: "failed",
|
|
729
|
+
CANCELLED: "cancelled",
|
|
730
|
+
});
|
|
731
|
+
const _strgovPTrans = new Map([
|
|
732
|
+
[
|
|
733
|
+
STRGOV_PROFILE_MATURITY_V2.PENDING,
|
|
734
|
+
new Set([
|
|
735
|
+
STRGOV_PROFILE_MATURITY_V2.ACTIVE,
|
|
736
|
+
STRGOV_PROFILE_MATURITY_V2.ARCHIVED,
|
|
737
|
+
]),
|
|
738
|
+
],
|
|
739
|
+
[
|
|
740
|
+
STRGOV_PROFILE_MATURITY_V2.ACTIVE,
|
|
741
|
+
new Set([
|
|
742
|
+
STRGOV_PROFILE_MATURITY_V2.STALE,
|
|
743
|
+
STRGOV_PROFILE_MATURITY_V2.ARCHIVED,
|
|
744
|
+
]),
|
|
745
|
+
],
|
|
746
|
+
[
|
|
747
|
+
STRGOV_PROFILE_MATURITY_V2.STALE,
|
|
748
|
+
new Set([
|
|
749
|
+
STRGOV_PROFILE_MATURITY_V2.ACTIVE,
|
|
750
|
+
STRGOV_PROFILE_MATURITY_V2.ARCHIVED,
|
|
751
|
+
]),
|
|
752
|
+
],
|
|
753
|
+
[STRGOV_PROFILE_MATURITY_V2.ARCHIVED, new Set()],
|
|
754
|
+
]);
|
|
755
|
+
const _strgovPTerminal = new Set([STRGOV_PROFILE_MATURITY_V2.ARCHIVED]);
|
|
756
|
+
const _strgovJTrans = new Map([
|
|
757
|
+
[
|
|
758
|
+
STRGOV_RUN_LIFECYCLE_V2.QUEUED,
|
|
759
|
+
new Set([
|
|
760
|
+
STRGOV_RUN_LIFECYCLE_V2.RUNNING,
|
|
761
|
+
STRGOV_RUN_LIFECYCLE_V2.CANCELLED,
|
|
762
|
+
]),
|
|
763
|
+
],
|
|
764
|
+
[
|
|
765
|
+
STRGOV_RUN_LIFECYCLE_V2.RUNNING,
|
|
766
|
+
new Set([
|
|
767
|
+
STRGOV_RUN_LIFECYCLE_V2.COMPLETED,
|
|
768
|
+
STRGOV_RUN_LIFECYCLE_V2.FAILED,
|
|
769
|
+
STRGOV_RUN_LIFECYCLE_V2.CANCELLED,
|
|
770
|
+
]),
|
|
771
|
+
],
|
|
772
|
+
[STRGOV_RUN_LIFECYCLE_V2.COMPLETED, new Set()],
|
|
773
|
+
[STRGOV_RUN_LIFECYCLE_V2.FAILED, new Set()],
|
|
774
|
+
[STRGOV_RUN_LIFECYCLE_V2.CANCELLED, new Set()],
|
|
775
|
+
]);
|
|
776
|
+
const _strgovPsV2 = new Map();
|
|
777
|
+
const _strgovJsV2 = new Map();
|
|
778
|
+
let _strgovMaxActive = 5,
|
|
779
|
+
_strgovMaxPending = 10,
|
|
780
|
+
_strgovIdleMs = 30 * 24 * 60 * 60 * 1000,
|
|
781
|
+
_strgovStuckMs = 60 * 1000;
|
|
782
|
+
function _strgovPos(n, label) {
|
|
783
|
+
const v = Math.floor(Number(n));
|
|
784
|
+
if (!Number.isFinite(v) || v <= 0)
|
|
785
|
+
throw new Error(`${label} must be positive integer`);
|
|
786
|
+
return v;
|
|
787
|
+
}
|
|
788
|
+
function _strgovCheckP(from, to) {
|
|
789
|
+
const a = _strgovPTrans.get(from);
|
|
790
|
+
if (!a || !a.has(to))
|
|
791
|
+
throw new Error(`invalid strgov profile transition ${from} → ${to}`);
|
|
792
|
+
}
|
|
793
|
+
function _strgovCheckJ(from, to) {
|
|
794
|
+
const a = _strgovJTrans.get(from);
|
|
795
|
+
if (!a || !a.has(to))
|
|
796
|
+
throw new Error(`invalid strgov run transition ${from} → ${to}`);
|
|
797
|
+
}
|
|
798
|
+
function _strgovCountActive(owner) {
|
|
799
|
+
let c = 0;
|
|
800
|
+
for (const p of _strgovPsV2.values())
|
|
801
|
+
if (p.owner === owner && p.status === STRGOV_PROFILE_MATURITY_V2.ACTIVE)
|
|
802
|
+
c++;
|
|
803
|
+
return c;
|
|
804
|
+
}
|
|
805
|
+
function _strgovCountPending(profileId) {
|
|
806
|
+
let c = 0;
|
|
807
|
+
for (const j of _strgovJsV2.values())
|
|
808
|
+
if (
|
|
809
|
+
j.profileId === profileId &&
|
|
810
|
+
(j.status === STRGOV_RUN_LIFECYCLE_V2.QUEUED ||
|
|
811
|
+
j.status === STRGOV_RUN_LIFECYCLE_V2.RUNNING)
|
|
812
|
+
)
|
|
813
|
+
c++;
|
|
814
|
+
return c;
|
|
815
|
+
}
|
|
816
|
+
export function setMaxActiveStrgovProfilesPerOwnerV2(n) {
|
|
817
|
+
_strgovMaxActive = _strgovPos(n, "maxActiveStrgovProfilesPerOwner");
|
|
818
|
+
}
|
|
819
|
+
export function getMaxActiveStrgovProfilesPerOwnerV2() {
|
|
820
|
+
return _strgovMaxActive;
|
|
821
|
+
}
|
|
822
|
+
export function setMaxPendingStrgovRunsPerProfileV2(n) {
|
|
823
|
+
_strgovMaxPending = _strgovPos(n, "maxPendingStrgovRunsPerProfile");
|
|
824
|
+
}
|
|
825
|
+
export function getMaxPendingStrgovRunsPerProfileV2() {
|
|
826
|
+
return _strgovMaxPending;
|
|
827
|
+
}
|
|
828
|
+
export function setStrgovProfileIdleMsV2(n) {
|
|
829
|
+
_strgovIdleMs = _strgovPos(n, "strgovProfileIdleMs");
|
|
830
|
+
}
|
|
831
|
+
export function getStrgovProfileIdleMsV2() {
|
|
832
|
+
return _strgovIdleMs;
|
|
833
|
+
}
|
|
834
|
+
export function setStrgovRunStuckMsV2(n) {
|
|
835
|
+
_strgovStuckMs = _strgovPos(n, "strgovRunStuckMs");
|
|
836
|
+
}
|
|
837
|
+
export function getStrgovRunStuckMsV2() {
|
|
838
|
+
return _strgovStuckMs;
|
|
839
|
+
}
|
|
840
|
+
export function _resetStateStressTesterV2() {
|
|
841
|
+
_strgovPsV2.clear();
|
|
842
|
+
_strgovJsV2.clear();
|
|
843
|
+
_strgovMaxActive = 5;
|
|
844
|
+
_strgovMaxPending = 10;
|
|
845
|
+
_strgovIdleMs = 30 * 24 * 60 * 60 * 1000;
|
|
846
|
+
_strgovStuckMs = 60 * 1000;
|
|
847
|
+
}
|
|
848
|
+
export function registerStrgovProfileV2({
|
|
849
|
+
id,
|
|
850
|
+
owner,
|
|
851
|
+
scenario,
|
|
852
|
+
metadata,
|
|
853
|
+
} = {}) {
|
|
854
|
+
if (!id || !owner) throw new Error("id and owner required");
|
|
855
|
+
if (_strgovPsV2.has(id))
|
|
856
|
+
throw new Error(`strgov profile ${id} already exists`);
|
|
857
|
+
const now = Date.now();
|
|
858
|
+
const p = {
|
|
859
|
+
id,
|
|
860
|
+
owner,
|
|
861
|
+
scenario: scenario || "ramp",
|
|
862
|
+
status: STRGOV_PROFILE_MATURITY_V2.PENDING,
|
|
863
|
+
createdAt: now,
|
|
864
|
+
updatedAt: now,
|
|
865
|
+
lastTouchedAt: now,
|
|
866
|
+
activatedAt: null,
|
|
867
|
+
archivedAt: null,
|
|
868
|
+
metadata: { ...(metadata || {}) },
|
|
869
|
+
};
|
|
870
|
+
_strgovPsV2.set(id, p);
|
|
871
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
872
|
+
}
|
|
873
|
+
export function activateStrgovProfileV2(id) {
|
|
874
|
+
const p = _strgovPsV2.get(id);
|
|
875
|
+
if (!p) throw new Error(`strgov profile ${id} not found`);
|
|
876
|
+
const isInitial = p.status === STRGOV_PROFILE_MATURITY_V2.PENDING;
|
|
877
|
+
_strgovCheckP(p.status, STRGOV_PROFILE_MATURITY_V2.ACTIVE);
|
|
878
|
+
if (isInitial && _strgovCountActive(p.owner) >= _strgovMaxActive)
|
|
879
|
+
throw new Error(`max active strgov profiles for owner ${p.owner} reached`);
|
|
880
|
+
const now = Date.now();
|
|
881
|
+
p.status = STRGOV_PROFILE_MATURITY_V2.ACTIVE;
|
|
882
|
+
p.updatedAt = now;
|
|
883
|
+
p.lastTouchedAt = now;
|
|
884
|
+
if (!p.activatedAt) p.activatedAt = now;
|
|
885
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
886
|
+
}
|
|
887
|
+
export function staleStrgovProfileV2(id) {
|
|
888
|
+
const p = _strgovPsV2.get(id);
|
|
889
|
+
if (!p) throw new Error(`strgov profile ${id} not found`);
|
|
890
|
+
_strgovCheckP(p.status, STRGOV_PROFILE_MATURITY_V2.STALE);
|
|
891
|
+
p.status = STRGOV_PROFILE_MATURITY_V2.STALE;
|
|
892
|
+
p.updatedAt = Date.now();
|
|
893
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
894
|
+
}
|
|
895
|
+
export function archiveStrgovProfileV2(id) {
|
|
896
|
+
const p = _strgovPsV2.get(id);
|
|
897
|
+
if (!p) throw new Error(`strgov profile ${id} not found`);
|
|
898
|
+
_strgovCheckP(p.status, STRGOV_PROFILE_MATURITY_V2.ARCHIVED);
|
|
899
|
+
const now = Date.now();
|
|
900
|
+
p.status = STRGOV_PROFILE_MATURITY_V2.ARCHIVED;
|
|
901
|
+
p.updatedAt = now;
|
|
902
|
+
if (!p.archivedAt) p.archivedAt = now;
|
|
903
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
904
|
+
}
|
|
905
|
+
export function touchStrgovProfileV2(id) {
|
|
906
|
+
const p = _strgovPsV2.get(id);
|
|
907
|
+
if (!p) throw new Error(`strgov profile ${id} not found`);
|
|
908
|
+
if (_strgovPTerminal.has(p.status))
|
|
909
|
+
throw new Error(`cannot touch terminal strgov profile ${id}`);
|
|
910
|
+
const now = Date.now();
|
|
911
|
+
p.lastTouchedAt = now;
|
|
912
|
+
p.updatedAt = now;
|
|
913
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
914
|
+
}
|
|
915
|
+
export function getStrgovProfileV2(id) {
|
|
916
|
+
const p = _strgovPsV2.get(id);
|
|
917
|
+
if (!p) return null;
|
|
918
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
919
|
+
}
|
|
920
|
+
export function listStrgovProfilesV2() {
|
|
921
|
+
return [..._strgovPsV2.values()].map((p) => ({
|
|
922
|
+
...p,
|
|
923
|
+
metadata: { ...p.metadata },
|
|
924
|
+
}));
|
|
925
|
+
}
|
|
926
|
+
export function createStrgovRunV2({
|
|
927
|
+
id,
|
|
928
|
+
profileId,
|
|
929
|
+
profileRef,
|
|
930
|
+
metadata,
|
|
931
|
+
} = {}) {
|
|
932
|
+
if (!id || !profileId) throw new Error("id and profileId required");
|
|
933
|
+
if (_strgovJsV2.has(id)) throw new Error(`strgov run ${id} already exists`);
|
|
934
|
+
if (!_strgovPsV2.has(profileId))
|
|
935
|
+
throw new Error(`strgov profile ${profileId} not found`);
|
|
936
|
+
if (_strgovCountPending(profileId) >= _strgovMaxPending)
|
|
937
|
+
throw new Error(`max pending strgov runs for profile ${profileId} reached`);
|
|
938
|
+
const now = Date.now();
|
|
939
|
+
const j = {
|
|
940
|
+
id,
|
|
941
|
+
profileId,
|
|
942
|
+
profileRef: profileRef || "",
|
|
943
|
+
status: STRGOV_RUN_LIFECYCLE_V2.QUEUED,
|
|
944
|
+
createdAt: now,
|
|
945
|
+
updatedAt: now,
|
|
946
|
+
startedAt: null,
|
|
947
|
+
settledAt: null,
|
|
948
|
+
metadata: { ...(metadata || {}) },
|
|
949
|
+
};
|
|
950
|
+
_strgovJsV2.set(id, j);
|
|
951
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
952
|
+
}
|
|
953
|
+
export function runningStrgovRunV2(id) {
|
|
954
|
+
const j = _strgovJsV2.get(id);
|
|
955
|
+
if (!j) throw new Error(`strgov run ${id} not found`);
|
|
956
|
+
_strgovCheckJ(j.status, STRGOV_RUN_LIFECYCLE_V2.RUNNING);
|
|
957
|
+
const now = Date.now();
|
|
958
|
+
j.status = STRGOV_RUN_LIFECYCLE_V2.RUNNING;
|
|
959
|
+
j.updatedAt = now;
|
|
960
|
+
if (!j.startedAt) j.startedAt = now;
|
|
961
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
962
|
+
}
|
|
963
|
+
export function completeRunStrgovV2(id) {
|
|
964
|
+
const j = _strgovJsV2.get(id);
|
|
965
|
+
if (!j) throw new Error(`strgov run ${id} not found`);
|
|
966
|
+
_strgovCheckJ(j.status, STRGOV_RUN_LIFECYCLE_V2.COMPLETED);
|
|
967
|
+
const now = Date.now();
|
|
968
|
+
j.status = STRGOV_RUN_LIFECYCLE_V2.COMPLETED;
|
|
969
|
+
j.updatedAt = now;
|
|
970
|
+
if (!j.settledAt) j.settledAt = now;
|
|
971
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
972
|
+
}
|
|
973
|
+
export function failStrgovRunV2(id, reason) {
|
|
974
|
+
const j = _strgovJsV2.get(id);
|
|
975
|
+
if (!j) throw new Error(`strgov run ${id} not found`);
|
|
976
|
+
_strgovCheckJ(j.status, STRGOV_RUN_LIFECYCLE_V2.FAILED);
|
|
977
|
+
const now = Date.now();
|
|
978
|
+
j.status = STRGOV_RUN_LIFECYCLE_V2.FAILED;
|
|
979
|
+
j.updatedAt = now;
|
|
980
|
+
if (!j.settledAt) j.settledAt = now;
|
|
981
|
+
if (reason) j.metadata.failReason = String(reason);
|
|
982
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
983
|
+
}
|
|
984
|
+
export function cancelStrgovRunV2(id, reason) {
|
|
985
|
+
const j = _strgovJsV2.get(id);
|
|
986
|
+
if (!j) throw new Error(`strgov run ${id} not found`);
|
|
987
|
+
_strgovCheckJ(j.status, STRGOV_RUN_LIFECYCLE_V2.CANCELLED);
|
|
988
|
+
const now = Date.now();
|
|
989
|
+
j.status = STRGOV_RUN_LIFECYCLE_V2.CANCELLED;
|
|
990
|
+
j.updatedAt = now;
|
|
991
|
+
if (!j.settledAt) j.settledAt = now;
|
|
992
|
+
if (reason) j.metadata.cancelReason = String(reason);
|
|
993
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
994
|
+
}
|
|
995
|
+
export function getStrgovRunV2(id) {
|
|
996
|
+
const j = _strgovJsV2.get(id);
|
|
997
|
+
if (!j) return null;
|
|
998
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
999
|
+
}
|
|
1000
|
+
export function listStrgovRunsV2() {
|
|
1001
|
+
return [..._strgovJsV2.values()].map((j) => ({
|
|
1002
|
+
...j,
|
|
1003
|
+
metadata: { ...j.metadata },
|
|
1004
|
+
}));
|
|
1005
|
+
}
|
|
1006
|
+
export function autoStaleIdleStrgovProfilesV2({ now } = {}) {
|
|
1007
|
+
const t = now ?? Date.now();
|
|
1008
|
+
const flipped = [];
|
|
1009
|
+
for (const p of _strgovPsV2.values())
|
|
1010
|
+
if (
|
|
1011
|
+
p.status === STRGOV_PROFILE_MATURITY_V2.ACTIVE &&
|
|
1012
|
+
t - p.lastTouchedAt >= _strgovIdleMs
|
|
1013
|
+
) {
|
|
1014
|
+
p.status = STRGOV_PROFILE_MATURITY_V2.STALE;
|
|
1015
|
+
p.updatedAt = t;
|
|
1016
|
+
flipped.push(p.id);
|
|
1017
|
+
}
|
|
1018
|
+
return { flipped, count: flipped.length };
|
|
1019
|
+
}
|
|
1020
|
+
export function autoFailStuckStrgovRunsV2({ now } = {}) {
|
|
1021
|
+
const t = now ?? Date.now();
|
|
1022
|
+
const flipped = [];
|
|
1023
|
+
for (const j of _strgovJsV2.values())
|
|
1024
|
+
if (
|
|
1025
|
+
j.status === STRGOV_RUN_LIFECYCLE_V2.RUNNING &&
|
|
1026
|
+
j.startedAt != null &&
|
|
1027
|
+
t - j.startedAt >= _strgovStuckMs
|
|
1028
|
+
) {
|
|
1029
|
+
j.status = STRGOV_RUN_LIFECYCLE_V2.FAILED;
|
|
1030
|
+
j.updatedAt = t;
|
|
1031
|
+
if (!j.settledAt) j.settledAt = t;
|
|
1032
|
+
j.metadata.failReason = "auto-fail-stuck";
|
|
1033
|
+
flipped.push(j.id);
|
|
1034
|
+
}
|
|
1035
|
+
return { flipped, count: flipped.length };
|
|
1036
|
+
}
|
|
1037
|
+
export function getStressTesterGovStatsV2() {
|
|
1038
|
+
const profilesByStatus = {};
|
|
1039
|
+
for (const v of Object.values(STRGOV_PROFILE_MATURITY_V2))
|
|
1040
|
+
profilesByStatus[v] = 0;
|
|
1041
|
+
for (const p of _strgovPsV2.values()) profilesByStatus[p.status]++;
|
|
1042
|
+
const runsByStatus = {};
|
|
1043
|
+
for (const v of Object.values(STRGOV_RUN_LIFECYCLE_V2)) runsByStatus[v] = 0;
|
|
1044
|
+
for (const j of _strgovJsV2.values()) runsByStatus[j.status]++;
|
|
1045
|
+
return {
|
|
1046
|
+
totalStrgovProfilesV2: _strgovPsV2.size,
|
|
1047
|
+
totalStrgovRunsV2: _strgovJsV2.size,
|
|
1048
|
+
maxActiveStrgovProfilesPerOwner: _strgovMaxActive,
|
|
1049
|
+
maxPendingStrgovRunsPerProfile: _strgovMaxPending,
|
|
1050
|
+
strgovProfileIdleMs: _strgovIdleMs,
|
|
1051
|
+
strgovRunStuckMs: _strgovStuckMs,
|
|
1052
|
+
profilesByStatus,
|
|
1053
|
+
runsByStatus,
|
|
1054
|
+
};
|
|
1055
|
+
}
|