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/token-tracker.js
CHANGED
|
@@ -527,3 +527,339 @@ export function _resetStateTokenTrackerV2() {
|
|
|
527
527
|
_budgetIdleMsV2 = TOKEN_DEFAULT_BUDGET_IDLE_MS;
|
|
528
528
|
_recordStuckMsV2 = TOKEN_DEFAULT_RECORD_STUCK_MS;
|
|
529
529
|
}
|
|
530
|
+
|
|
531
|
+
// =====================================================================
|
|
532
|
+
// token-tracker V2 governance overlay (iter24)
|
|
533
|
+
// =====================================================================
|
|
534
|
+
export const TOKTGOV_PROFILE_MATURITY_V2 = Object.freeze({
|
|
535
|
+
PENDING: "pending",
|
|
536
|
+
ACTIVE: "active",
|
|
537
|
+
STALE: "stale",
|
|
538
|
+
ARCHIVED: "archived",
|
|
539
|
+
});
|
|
540
|
+
export const TOKTGOV_USAGE_LIFECYCLE_V2 = Object.freeze({
|
|
541
|
+
QUEUED: "queued",
|
|
542
|
+
RECORDING: "recording",
|
|
543
|
+
RECORDED: "recorded",
|
|
544
|
+
FAILED: "failed",
|
|
545
|
+
CANCELLED: "cancelled",
|
|
546
|
+
});
|
|
547
|
+
const _toktgovPTrans = new Map([
|
|
548
|
+
[
|
|
549
|
+
TOKTGOV_PROFILE_MATURITY_V2.PENDING,
|
|
550
|
+
new Set([
|
|
551
|
+
TOKTGOV_PROFILE_MATURITY_V2.ACTIVE,
|
|
552
|
+
TOKTGOV_PROFILE_MATURITY_V2.ARCHIVED,
|
|
553
|
+
]),
|
|
554
|
+
],
|
|
555
|
+
[
|
|
556
|
+
TOKTGOV_PROFILE_MATURITY_V2.ACTIVE,
|
|
557
|
+
new Set([
|
|
558
|
+
TOKTGOV_PROFILE_MATURITY_V2.STALE,
|
|
559
|
+
TOKTGOV_PROFILE_MATURITY_V2.ARCHIVED,
|
|
560
|
+
]),
|
|
561
|
+
],
|
|
562
|
+
[
|
|
563
|
+
TOKTGOV_PROFILE_MATURITY_V2.STALE,
|
|
564
|
+
new Set([
|
|
565
|
+
TOKTGOV_PROFILE_MATURITY_V2.ACTIVE,
|
|
566
|
+
TOKTGOV_PROFILE_MATURITY_V2.ARCHIVED,
|
|
567
|
+
]),
|
|
568
|
+
],
|
|
569
|
+
[TOKTGOV_PROFILE_MATURITY_V2.ARCHIVED, new Set()],
|
|
570
|
+
]);
|
|
571
|
+
const _toktgovPTerminal = new Set([TOKTGOV_PROFILE_MATURITY_V2.ARCHIVED]);
|
|
572
|
+
const _toktgovJTrans = new Map([
|
|
573
|
+
[
|
|
574
|
+
TOKTGOV_USAGE_LIFECYCLE_V2.QUEUED,
|
|
575
|
+
new Set([
|
|
576
|
+
TOKTGOV_USAGE_LIFECYCLE_V2.RECORDING,
|
|
577
|
+
TOKTGOV_USAGE_LIFECYCLE_V2.CANCELLED,
|
|
578
|
+
]),
|
|
579
|
+
],
|
|
580
|
+
[
|
|
581
|
+
TOKTGOV_USAGE_LIFECYCLE_V2.RECORDING,
|
|
582
|
+
new Set([
|
|
583
|
+
TOKTGOV_USAGE_LIFECYCLE_V2.RECORDED,
|
|
584
|
+
TOKTGOV_USAGE_LIFECYCLE_V2.FAILED,
|
|
585
|
+
TOKTGOV_USAGE_LIFECYCLE_V2.CANCELLED,
|
|
586
|
+
]),
|
|
587
|
+
],
|
|
588
|
+
[TOKTGOV_USAGE_LIFECYCLE_V2.RECORDED, new Set()],
|
|
589
|
+
[TOKTGOV_USAGE_LIFECYCLE_V2.FAILED, new Set()],
|
|
590
|
+
[TOKTGOV_USAGE_LIFECYCLE_V2.CANCELLED, new Set()],
|
|
591
|
+
]);
|
|
592
|
+
const _toktgovPsV2 = new Map();
|
|
593
|
+
const _toktgovJsV2 = new Map();
|
|
594
|
+
let _toktgovMaxActive = 8,
|
|
595
|
+
_toktgovMaxPending = 20,
|
|
596
|
+
_toktgovIdleMs = 30 * 24 * 60 * 60 * 1000,
|
|
597
|
+
_toktgovStuckMs = 60 * 1000;
|
|
598
|
+
function _toktgovPos(n, label) {
|
|
599
|
+
const v = Math.floor(Number(n));
|
|
600
|
+
if (!Number.isFinite(v) || v <= 0)
|
|
601
|
+
throw new Error(`${label} must be positive integer`);
|
|
602
|
+
return v;
|
|
603
|
+
}
|
|
604
|
+
function _toktgovCheckP(from, to) {
|
|
605
|
+
const a = _toktgovPTrans.get(from);
|
|
606
|
+
if (!a || !a.has(to))
|
|
607
|
+
throw new Error(`invalid toktgov profile transition ${from} → ${to}`);
|
|
608
|
+
}
|
|
609
|
+
function _toktgovCheckJ(from, to) {
|
|
610
|
+
const a = _toktgovJTrans.get(from);
|
|
611
|
+
if (!a || !a.has(to))
|
|
612
|
+
throw new Error(`invalid toktgov usage transition ${from} → ${to}`);
|
|
613
|
+
}
|
|
614
|
+
function _toktgovCountActive(owner) {
|
|
615
|
+
let c = 0;
|
|
616
|
+
for (const p of _toktgovPsV2.values())
|
|
617
|
+
if (p.owner === owner && p.status === TOKTGOV_PROFILE_MATURITY_V2.ACTIVE)
|
|
618
|
+
c++;
|
|
619
|
+
return c;
|
|
620
|
+
}
|
|
621
|
+
function _toktgovCountPending(profileId) {
|
|
622
|
+
let c = 0;
|
|
623
|
+
for (const j of _toktgovJsV2.values())
|
|
624
|
+
if (
|
|
625
|
+
j.profileId === profileId &&
|
|
626
|
+
(j.status === TOKTGOV_USAGE_LIFECYCLE_V2.QUEUED ||
|
|
627
|
+
j.status === TOKTGOV_USAGE_LIFECYCLE_V2.RECORDING)
|
|
628
|
+
)
|
|
629
|
+
c++;
|
|
630
|
+
return c;
|
|
631
|
+
}
|
|
632
|
+
export function setMaxActiveToktgovProfilesPerOwnerV2(n) {
|
|
633
|
+
_toktgovMaxActive = _toktgovPos(n, "maxActiveToktgovProfilesPerOwner");
|
|
634
|
+
}
|
|
635
|
+
export function getMaxActiveToktgovProfilesPerOwnerV2() {
|
|
636
|
+
return _toktgovMaxActive;
|
|
637
|
+
}
|
|
638
|
+
export function setMaxPendingToktgovUsagesPerProfileV2(n) {
|
|
639
|
+
_toktgovMaxPending = _toktgovPos(n, "maxPendingToktgovUsagesPerProfile");
|
|
640
|
+
}
|
|
641
|
+
export function getMaxPendingToktgovUsagesPerProfileV2() {
|
|
642
|
+
return _toktgovMaxPending;
|
|
643
|
+
}
|
|
644
|
+
export function setToktgovProfileIdleMsV2(n) {
|
|
645
|
+
_toktgovIdleMs = _toktgovPos(n, "toktgovProfileIdleMs");
|
|
646
|
+
}
|
|
647
|
+
export function getToktgovProfileIdleMsV2() {
|
|
648
|
+
return _toktgovIdleMs;
|
|
649
|
+
}
|
|
650
|
+
export function setToktgovUsageStuckMsV2(n) {
|
|
651
|
+
_toktgovStuckMs = _toktgovPos(n, "toktgovUsageStuckMs");
|
|
652
|
+
}
|
|
653
|
+
export function getToktgovUsageStuckMsV2() {
|
|
654
|
+
return _toktgovStuckMs;
|
|
655
|
+
}
|
|
656
|
+
export function _resetStateTokenTrackerGovV2() {
|
|
657
|
+
_toktgovPsV2.clear();
|
|
658
|
+
_toktgovJsV2.clear();
|
|
659
|
+
_toktgovMaxActive = 8;
|
|
660
|
+
_toktgovMaxPending = 20;
|
|
661
|
+
_toktgovIdleMs = 30 * 24 * 60 * 60 * 1000;
|
|
662
|
+
_toktgovStuckMs = 60 * 1000;
|
|
663
|
+
}
|
|
664
|
+
export function registerToktgovProfileV2({ id, owner, budget, metadata } = {}) {
|
|
665
|
+
if (!id || !owner) throw new Error("id and owner required");
|
|
666
|
+
if (_toktgovPsV2.has(id))
|
|
667
|
+
throw new Error(`toktgov profile ${id} already exists`);
|
|
668
|
+
const now = Date.now();
|
|
669
|
+
const p = {
|
|
670
|
+
id,
|
|
671
|
+
owner,
|
|
672
|
+
budget: budget || "default",
|
|
673
|
+
status: TOKTGOV_PROFILE_MATURITY_V2.PENDING,
|
|
674
|
+
createdAt: now,
|
|
675
|
+
updatedAt: now,
|
|
676
|
+
lastTouchedAt: now,
|
|
677
|
+
activatedAt: null,
|
|
678
|
+
archivedAt: null,
|
|
679
|
+
metadata: { ...(metadata || {}) },
|
|
680
|
+
};
|
|
681
|
+
_toktgovPsV2.set(id, p);
|
|
682
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
683
|
+
}
|
|
684
|
+
export function activateToktgovProfileV2(id) {
|
|
685
|
+
const p = _toktgovPsV2.get(id);
|
|
686
|
+
if (!p) throw new Error(`toktgov profile ${id} not found`);
|
|
687
|
+
const isInitial = p.status === TOKTGOV_PROFILE_MATURITY_V2.PENDING;
|
|
688
|
+
_toktgovCheckP(p.status, TOKTGOV_PROFILE_MATURITY_V2.ACTIVE);
|
|
689
|
+
if (isInitial && _toktgovCountActive(p.owner) >= _toktgovMaxActive)
|
|
690
|
+
throw new Error(`max active toktgov profiles for owner ${p.owner} reached`);
|
|
691
|
+
const now = Date.now();
|
|
692
|
+
p.status = TOKTGOV_PROFILE_MATURITY_V2.ACTIVE;
|
|
693
|
+
p.updatedAt = now;
|
|
694
|
+
p.lastTouchedAt = now;
|
|
695
|
+
if (!p.activatedAt) p.activatedAt = now;
|
|
696
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
697
|
+
}
|
|
698
|
+
export function staleToktgovProfileV2(id) {
|
|
699
|
+
const p = _toktgovPsV2.get(id);
|
|
700
|
+
if (!p) throw new Error(`toktgov profile ${id} not found`);
|
|
701
|
+
_toktgovCheckP(p.status, TOKTGOV_PROFILE_MATURITY_V2.STALE);
|
|
702
|
+
p.status = TOKTGOV_PROFILE_MATURITY_V2.STALE;
|
|
703
|
+
p.updatedAt = Date.now();
|
|
704
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
705
|
+
}
|
|
706
|
+
export function archiveToktgovProfileV2(id) {
|
|
707
|
+
const p = _toktgovPsV2.get(id);
|
|
708
|
+
if (!p) throw new Error(`toktgov profile ${id} not found`);
|
|
709
|
+
_toktgovCheckP(p.status, TOKTGOV_PROFILE_MATURITY_V2.ARCHIVED);
|
|
710
|
+
const now = Date.now();
|
|
711
|
+
p.status = TOKTGOV_PROFILE_MATURITY_V2.ARCHIVED;
|
|
712
|
+
p.updatedAt = now;
|
|
713
|
+
if (!p.archivedAt) p.archivedAt = now;
|
|
714
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
715
|
+
}
|
|
716
|
+
export function touchToktgovProfileV2(id) {
|
|
717
|
+
const p = _toktgovPsV2.get(id);
|
|
718
|
+
if (!p) throw new Error(`toktgov profile ${id} not found`);
|
|
719
|
+
if (_toktgovPTerminal.has(p.status))
|
|
720
|
+
throw new Error(`cannot touch terminal toktgov profile ${id}`);
|
|
721
|
+
const now = Date.now();
|
|
722
|
+
p.lastTouchedAt = now;
|
|
723
|
+
p.updatedAt = now;
|
|
724
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
725
|
+
}
|
|
726
|
+
export function getToktgovProfileV2(id) {
|
|
727
|
+
const p = _toktgovPsV2.get(id);
|
|
728
|
+
if (!p) return null;
|
|
729
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
730
|
+
}
|
|
731
|
+
export function listToktgovProfilesV2() {
|
|
732
|
+
return [..._toktgovPsV2.values()].map((p) => ({
|
|
733
|
+
...p,
|
|
734
|
+
metadata: { ...p.metadata },
|
|
735
|
+
}));
|
|
736
|
+
}
|
|
737
|
+
export function createToktgovUsageV2({ id, profileId, model, metadata } = {}) {
|
|
738
|
+
if (!id || !profileId) throw new Error("id and profileId required");
|
|
739
|
+
if (_toktgovJsV2.has(id))
|
|
740
|
+
throw new Error(`toktgov usage ${id} already exists`);
|
|
741
|
+
if (!_toktgovPsV2.has(profileId))
|
|
742
|
+
throw new Error(`toktgov profile ${profileId} not found`);
|
|
743
|
+
if (_toktgovCountPending(profileId) >= _toktgovMaxPending)
|
|
744
|
+
throw new Error(
|
|
745
|
+
`max pending toktgov usages for profile ${profileId} reached`,
|
|
746
|
+
);
|
|
747
|
+
const now = Date.now();
|
|
748
|
+
const j = {
|
|
749
|
+
id,
|
|
750
|
+
profileId,
|
|
751
|
+
model: model || "",
|
|
752
|
+
status: TOKTGOV_USAGE_LIFECYCLE_V2.QUEUED,
|
|
753
|
+
createdAt: now,
|
|
754
|
+
updatedAt: now,
|
|
755
|
+
startedAt: null,
|
|
756
|
+
settledAt: null,
|
|
757
|
+
metadata: { ...(metadata || {}) },
|
|
758
|
+
};
|
|
759
|
+
_toktgovJsV2.set(id, j);
|
|
760
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
761
|
+
}
|
|
762
|
+
export function recordingToktgovUsageV2(id) {
|
|
763
|
+
const j = _toktgovJsV2.get(id);
|
|
764
|
+
if (!j) throw new Error(`toktgov usage ${id} not found`);
|
|
765
|
+
_toktgovCheckJ(j.status, TOKTGOV_USAGE_LIFECYCLE_V2.RECORDING);
|
|
766
|
+
const now = Date.now();
|
|
767
|
+
j.status = TOKTGOV_USAGE_LIFECYCLE_V2.RECORDING;
|
|
768
|
+
j.updatedAt = now;
|
|
769
|
+
if (!j.startedAt) j.startedAt = now;
|
|
770
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
771
|
+
}
|
|
772
|
+
export function completeUsageToktgovV2(id) {
|
|
773
|
+
const j = _toktgovJsV2.get(id);
|
|
774
|
+
if (!j) throw new Error(`toktgov usage ${id} not found`);
|
|
775
|
+
_toktgovCheckJ(j.status, TOKTGOV_USAGE_LIFECYCLE_V2.RECORDED);
|
|
776
|
+
const now = Date.now();
|
|
777
|
+
j.status = TOKTGOV_USAGE_LIFECYCLE_V2.RECORDED;
|
|
778
|
+
j.updatedAt = now;
|
|
779
|
+
if (!j.settledAt) j.settledAt = now;
|
|
780
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
781
|
+
}
|
|
782
|
+
export function failToktgovUsageV2(id, reason) {
|
|
783
|
+
const j = _toktgovJsV2.get(id);
|
|
784
|
+
if (!j) throw new Error(`toktgov usage ${id} not found`);
|
|
785
|
+
_toktgovCheckJ(j.status, TOKTGOV_USAGE_LIFECYCLE_V2.FAILED);
|
|
786
|
+
const now = Date.now();
|
|
787
|
+
j.status = TOKTGOV_USAGE_LIFECYCLE_V2.FAILED;
|
|
788
|
+
j.updatedAt = now;
|
|
789
|
+
if (!j.settledAt) j.settledAt = now;
|
|
790
|
+
if (reason) j.metadata.failReason = String(reason);
|
|
791
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
792
|
+
}
|
|
793
|
+
export function cancelToktgovUsageV2(id, reason) {
|
|
794
|
+
const j = _toktgovJsV2.get(id);
|
|
795
|
+
if (!j) throw new Error(`toktgov usage ${id} not found`);
|
|
796
|
+
_toktgovCheckJ(j.status, TOKTGOV_USAGE_LIFECYCLE_V2.CANCELLED);
|
|
797
|
+
const now = Date.now();
|
|
798
|
+
j.status = TOKTGOV_USAGE_LIFECYCLE_V2.CANCELLED;
|
|
799
|
+
j.updatedAt = now;
|
|
800
|
+
if (!j.settledAt) j.settledAt = now;
|
|
801
|
+
if (reason) j.metadata.cancelReason = String(reason);
|
|
802
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
803
|
+
}
|
|
804
|
+
export function getToktgovUsageV2(id) {
|
|
805
|
+
const j = _toktgovJsV2.get(id);
|
|
806
|
+
if (!j) return null;
|
|
807
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
808
|
+
}
|
|
809
|
+
export function listToktgovUsagesV2() {
|
|
810
|
+
return [..._toktgovJsV2.values()].map((j) => ({
|
|
811
|
+
...j,
|
|
812
|
+
metadata: { ...j.metadata },
|
|
813
|
+
}));
|
|
814
|
+
}
|
|
815
|
+
export function autoStaleIdleToktgovProfilesV2({ now } = {}) {
|
|
816
|
+
const t = now ?? Date.now();
|
|
817
|
+
const flipped = [];
|
|
818
|
+
for (const p of _toktgovPsV2.values())
|
|
819
|
+
if (
|
|
820
|
+
p.status === TOKTGOV_PROFILE_MATURITY_V2.ACTIVE &&
|
|
821
|
+
t - p.lastTouchedAt >= _toktgovIdleMs
|
|
822
|
+
) {
|
|
823
|
+
p.status = TOKTGOV_PROFILE_MATURITY_V2.STALE;
|
|
824
|
+
p.updatedAt = t;
|
|
825
|
+
flipped.push(p.id);
|
|
826
|
+
}
|
|
827
|
+
return { flipped, count: flipped.length };
|
|
828
|
+
}
|
|
829
|
+
export function autoFailStuckToktgovUsagesV2({ now } = {}) {
|
|
830
|
+
const t = now ?? Date.now();
|
|
831
|
+
const flipped = [];
|
|
832
|
+
for (const j of _toktgovJsV2.values())
|
|
833
|
+
if (
|
|
834
|
+
j.status === TOKTGOV_USAGE_LIFECYCLE_V2.RECORDING &&
|
|
835
|
+
j.startedAt != null &&
|
|
836
|
+
t - j.startedAt >= _toktgovStuckMs
|
|
837
|
+
) {
|
|
838
|
+
j.status = TOKTGOV_USAGE_LIFECYCLE_V2.FAILED;
|
|
839
|
+
j.updatedAt = t;
|
|
840
|
+
if (!j.settledAt) j.settledAt = t;
|
|
841
|
+
j.metadata.failReason = "auto-fail-stuck";
|
|
842
|
+
flipped.push(j.id);
|
|
843
|
+
}
|
|
844
|
+
return { flipped, count: flipped.length };
|
|
845
|
+
}
|
|
846
|
+
export function getTokenTrackerGovStatsV2() {
|
|
847
|
+
const profilesByStatus = {};
|
|
848
|
+
for (const v of Object.values(TOKTGOV_PROFILE_MATURITY_V2))
|
|
849
|
+
profilesByStatus[v] = 0;
|
|
850
|
+
for (const p of _toktgovPsV2.values()) profilesByStatus[p.status]++;
|
|
851
|
+
const usagesByStatus = {};
|
|
852
|
+
for (const v of Object.values(TOKTGOV_USAGE_LIFECYCLE_V2))
|
|
853
|
+
usagesByStatus[v] = 0;
|
|
854
|
+
for (const j of _toktgovJsV2.values()) usagesByStatus[j.status]++;
|
|
855
|
+
return {
|
|
856
|
+
totalToktgovProfilesV2: _toktgovPsV2.size,
|
|
857
|
+
totalToktgovUsagesV2: _toktgovJsV2.size,
|
|
858
|
+
maxActiveToktgovProfilesPerOwner: _toktgovMaxActive,
|
|
859
|
+
maxPendingToktgovUsagesPerProfile: _toktgovMaxPending,
|
|
860
|
+
toktgovProfileIdleMs: _toktgovIdleMs,
|
|
861
|
+
toktgovUsageStuckMs: _toktgovStuckMs,
|
|
862
|
+
profilesByStatus,
|
|
863
|
+
usagesByStatus,
|
|
864
|
+
};
|
|
865
|
+
}
|
|
@@ -861,3 +861,346 @@ export function _resetStateV2() {
|
|
|
861
861
|
_tsDeviceIdleMs = TS_DEFAULT_DEVICE_IDLE_MS;
|
|
862
862
|
_tsTransmissionStuckMs = TS_DEFAULT_TRANSMISSION_STUCK_MS;
|
|
863
863
|
}
|
|
864
|
+
|
|
865
|
+
// =====================================================================
|
|
866
|
+
// trust-security V2 governance overlay (iter18)
|
|
867
|
+
// =====================================================================
|
|
868
|
+
export const TRUSTGOV_PROFILE_MATURITY_V2 = Object.freeze({
|
|
869
|
+
PENDING: "pending",
|
|
870
|
+
ACTIVE: "active",
|
|
871
|
+
SUSPENDED: "suspended",
|
|
872
|
+
ARCHIVED: "archived",
|
|
873
|
+
});
|
|
874
|
+
export const TRUSTGOV_CHECK_LIFECYCLE_V2 = Object.freeze({
|
|
875
|
+
QUEUED: "queued",
|
|
876
|
+
VERIFYING: "verifying",
|
|
877
|
+
VERIFIED: "verified",
|
|
878
|
+
FAILED: "failed",
|
|
879
|
+
CANCELLED: "cancelled",
|
|
880
|
+
});
|
|
881
|
+
const _trustgovPTrans = new Map([
|
|
882
|
+
[
|
|
883
|
+
TRUSTGOV_PROFILE_MATURITY_V2.PENDING,
|
|
884
|
+
new Set([
|
|
885
|
+
TRUSTGOV_PROFILE_MATURITY_V2.ACTIVE,
|
|
886
|
+
TRUSTGOV_PROFILE_MATURITY_V2.ARCHIVED,
|
|
887
|
+
]),
|
|
888
|
+
],
|
|
889
|
+
[
|
|
890
|
+
TRUSTGOV_PROFILE_MATURITY_V2.ACTIVE,
|
|
891
|
+
new Set([
|
|
892
|
+
TRUSTGOV_PROFILE_MATURITY_V2.SUSPENDED,
|
|
893
|
+
TRUSTGOV_PROFILE_MATURITY_V2.ARCHIVED,
|
|
894
|
+
]),
|
|
895
|
+
],
|
|
896
|
+
[
|
|
897
|
+
TRUSTGOV_PROFILE_MATURITY_V2.SUSPENDED,
|
|
898
|
+
new Set([
|
|
899
|
+
TRUSTGOV_PROFILE_MATURITY_V2.ACTIVE,
|
|
900
|
+
TRUSTGOV_PROFILE_MATURITY_V2.ARCHIVED,
|
|
901
|
+
]),
|
|
902
|
+
],
|
|
903
|
+
[TRUSTGOV_PROFILE_MATURITY_V2.ARCHIVED, new Set()],
|
|
904
|
+
]);
|
|
905
|
+
const _trustgovPTerminal = new Set([TRUSTGOV_PROFILE_MATURITY_V2.ARCHIVED]);
|
|
906
|
+
const _trustgovJTrans = new Map([
|
|
907
|
+
[
|
|
908
|
+
TRUSTGOV_CHECK_LIFECYCLE_V2.QUEUED,
|
|
909
|
+
new Set([
|
|
910
|
+
TRUSTGOV_CHECK_LIFECYCLE_V2.VERIFYING,
|
|
911
|
+
TRUSTGOV_CHECK_LIFECYCLE_V2.CANCELLED,
|
|
912
|
+
]),
|
|
913
|
+
],
|
|
914
|
+
[
|
|
915
|
+
TRUSTGOV_CHECK_LIFECYCLE_V2.VERIFYING,
|
|
916
|
+
new Set([
|
|
917
|
+
TRUSTGOV_CHECK_LIFECYCLE_V2.VERIFIED,
|
|
918
|
+
TRUSTGOV_CHECK_LIFECYCLE_V2.FAILED,
|
|
919
|
+
TRUSTGOV_CHECK_LIFECYCLE_V2.CANCELLED,
|
|
920
|
+
]),
|
|
921
|
+
],
|
|
922
|
+
[TRUSTGOV_CHECK_LIFECYCLE_V2.VERIFIED, new Set()],
|
|
923
|
+
[TRUSTGOV_CHECK_LIFECYCLE_V2.FAILED, new Set()],
|
|
924
|
+
[TRUSTGOV_CHECK_LIFECYCLE_V2.CANCELLED, new Set()],
|
|
925
|
+
]);
|
|
926
|
+
const _trustgovPsV2 = new Map();
|
|
927
|
+
const _trustgovJsV2 = new Map();
|
|
928
|
+
let _trustgovMaxActive = 8,
|
|
929
|
+
_trustgovMaxPending = 20,
|
|
930
|
+
_trustgovIdleMs = 30 * 24 * 60 * 60 * 1000,
|
|
931
|
+
_trustgovStuckMs = 60 * 1000;
|
|
932
|
+
function _trustgovPos(n, label) {
|
|
933
|
+
const v = Math.floor(Number(n));
|
|
934
|
+
if (!Number.isFinite(v) || v <= 0)
|
|
935
|
+
throw new Error(`${label} must be positive integer`);
|
|
936
|
+
return v;
|
|
937
|
+
}
|
|
938
|
+
function _trustgovCheckP(from, to) {
|
|
939
|
+
const a = _trustgovPTrans.get(from);
|
|
940
|
+
if (!a || !a.has(to))
|
|
941
|
+
throw new Error(`invalid trustgov profile transition ${from} → ${to}`);
|
|
942
|
+
}
|
|
943
|
+
function _trustgovCheckJ(from, to) {
|
|
944
|
+
const a = _trustgovJTrans.get(from);
|
|
945
|
+
if (!a || !a.has(to))
|
|
946
|
+
throw new Error(`invalid trustgov check transition ${from} → ${to}`);
|
|
947
|
+
}
|
|
948
|
+
function _trustgovCountActive(owner) {
|
|
949
|
+
let c = 0;
|
|
950
|
+
for (const p of _trustgovPsV2.values())
|
|
951
|
+
if (p.owner === owner && p.status === TRUSTGOV_PROFILE_MATURITY_V2.ACTIVE)
|
|
952
|
+
c++;
|
|
953
|
+
return c;
|
|
954
|
+
}
|
|
955
|
+
function _trustgovCountPending(profileId) {
|
|
956
|
+
let c = 0;
|
|
957
|
+
for (const j of _trustgovJsV2.values())
|
|
958
|
+
if (
|
|
959
|
+
j.profileId === profileId &&
|
|
960
|
+
(j.status === TRUSTGOV_CHECK_LIFECYCLE_V2.QUEUED ||
|
|
961
|
+
j.status === TRUSTGOV_CHECK_LIFECYCLE_V2.VERIFYING)
|
|
962
|
+
)
|
|
963
|
+
c++;
|
|
964
|
+
return c;
|
|
965
|
+
}
|
|
966
|
+
export function setMaxActiveTrustgovProfilesPerOwnerV2(n) {
|
|
967
|
+
_trustgovMaxActive = _trustgovPos(n, "maxActiveTrustgovProfilesPerOwner");
|
|
968
|
+
}
|
|
969
|
+
export function getMaxActiveTrustgovProfilesPerOwnerV2() {
|
|
970
|
+
return _trustgovMaxActive;
|
|
971
|
+
}
|
|
972
|
+
export function setMaxPendingTrustgovChecksPerProfileV2(n) {
|
|
973
|
+
_trustgovMaxPending = _trustgovPos(n, "maxPendingTrustgovChecksPerProfile");
|
|
974
|
+
}
|
|
975
|
+
export function getMaxPendingTrustgovChecksPerProfileV2() {
|
|
976
|
+
return _trustgovMaxPending;
|
|
977
|
+
}
|
|
978
|
+
export function setTrustgovProfileIdleMsV2(n) {
|
|
979
|
+
_trustgovIdleMs = _trustgovPos(n, "trustgovProfileIdleMs");
|
|
980
|
+
}
|
|
981
|
+
export function getTrustgovProfileIdleMsV2() {
|
|
982
|
+
return _trustgovIdleMs;
|
|
983
|
+
}
|
|
984
|
+
export function setTrustgovCheckStuckMsV2(n) {
|
|
985
|
+
_trustgovStuckMs = _trustgovPos(n, "trustgovCheckStuckMs");
|
|
986
|
+
}
|
|
987
|
+
export function getTrustgovCheckStuckMsV2() {
|
|
988
|
+
return _trustgovStuckMs;
|
|
989
|
+
}
|
|
990
|
+
export function _resetStateTrustSecurityGovV2() {
|
|
991
|
+
_trustgovPsV2.clear();
|
|
992
|
+
_trustgovJsV2.clear();
|
|
993
|
+
_trustgovMaxActive = 8;
|
|
994
|
+
_trustgovMaxPending = 20;
|
|
995
|
+
_trustgovIdleMs = 30 * 24 * 60 * 60 * 1000;
|
|
996
|
+
_trustgovStuckMs = 60 * 1000;
|
|
997
|
+
}
|
|
998
|
+
export function registerTrustgovProfileV2({ id, owner, level, metadata } = {}) {
|
|
999
|
+
if (!id || !owner) throw new Error("id and owner required");
|
|
1000
|
+
if (_trustgovPsV2.has(id))
|
|
1001
|
+
throw new Error(`trustgov profile ${id} already exists`);
|
|
1002
|
+
const now = Date.now();
|
|
1003
|
+
const p = {
|
|
1004
|
+
id,
|
|
1005
|
+
owner,
|
|
1006
|
+
level: level || "medium",
|
|
1007
|
+
status: TRUSTGOV_PROFILE_MATURITY_V2.PENDING,
|
|
1008
|
+
createdAt: now,
|
|
1009
|
+
updatedAt: now,
|
|
1010
|
+
lastTouchedAt: now,
|
|
1011
|
+
activatedAt: null,
|
|
1012
|
+
archivedAt: null,
|
|
1013
|
+
metadata: { ...(metadata || {}) },
|
|
1014
|
+
};
|
|
1015
|
+
_trustgovPsV2.set(id, p);
|
|
1016
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
1017
|
+
}
|
|
1018
|
+
export function activateTrustgovProfileV2(id) {
|
|
1019
|
+
const p = _trustgovPsV2.get(id);
|
|
1020
|
+
if (!p) throw new Error(`trustgov profile ${id} not found`);
|
|
1021
|
+
const isInitial = p.status === TRUSTGOV_PROFILE_MATURITY_V2.PENDING;
|
|
1022
|
+
_trustgovCheckP(p.status, TRUSTGOV_PROFILE_MATURITY_V2.ACTIVE);
|
|
1023
|
+
if (isInitial && _trustgovCountActive(p.owner) >= _trustgovMaxActive)
|
|
1024
|
+
throw new Error(
|
|
1025
|
+
`max active trustgov profiles for owner ${p.owner} reached`,
|
|
1026
|
+
);
|
|
1027
|
+
const now = Date.now();
|
|
1028
|
+
p.status = TRUSTGOV_PROFILE_MATURITY_V2.ACTIVE;
|
|
1029
|
+
p.updatedAt = now;
|
|
1030
|
+
p.lastTouchedAt = now;
|
|
1031
|
+
if (!p.activatedAt) p.activatedAt = now;
|
|
1032
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
1033
|
+
}
|
|
1034
|
+
export function suspendTrustgovProfileV2(id) {
|
|
1035
|
+
const p = _trustgovPsV2.get(id);
|
|
1036
|
+
if (!p) throw new Error(`trustgov profile ${id} not found`);
|
|
1037
|
+
_trustgovCheckP(p.status, TRUSTGOV_PROFILE_MATURITY_V2.SUSPENDED);
|
|
1038
|
+
p.status = TRUSTGOV_PROFILE_MATURITY_V2.SUSPENDED;
|
|
1039
|
+
p.updatedAt = Date.now();
|
|
1040
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
1041
|
+
}
|
|
1042
|
+
export function archiveTrustgovProfileV2(id) {
|
|
1043
|
+
const p = _trustgovPsV2.get(id);
|
|
1044
|
+
if (!p) throw new Error(`trustgov profile ${id} not found`);
|
|
1045
|
+
_trustgovCheckP(p.status, TRUSTGOV_PROFILE_MATURITY_V2.ARCHIVED);
|
|
1046
|
+
const now = Date.now();
|
|
1047
|
+
p.status = TRUSTGOV_PROFILE_MATURITY_V2.ARCHIVED;
|
|
1048
|
+
p.updatedAt = now;
|
|
1049
|
+
if (!p.archivedAt) p.archivedAt = now;
|
|
1050
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
1051
|
+
}
|
|
1052
|
+
export function touchTrustgovProfileV2(id) {
|
|
1053
|
+
const p = _trustgovPsV2.get(id);
|
|
1054
|
+
if (!p) throw new Error(`trustgov profile ${id} not found`);
|
|
1055
|
+
if (_trustgovPTerminal.has(p.status))
|
|
1056
|
+
throw new Error(`cannot touch terminal trustgov profile ${id}`);
|
|
1057
|
+
const now = Date.now();
|
|
1058
|
+
p.lastTouchedAt = now;
|
|
1059
|
+
p.updatedAt = now;
|
|
1060
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
1061
|
+
}
|
|
1062
|
+
export function getTrustgovProfileV2(id) {
|
|
1063
|
+
const p = _trustgovPsV2.get(id);
|
|
1064
|
+
if (!p) return null;
|
|
1065
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
1066
|
+
}
|
|
1067
|
+
export function listTrustgovProfilesV2() {
|
|
1068
|
+
return [..._trustgovPsV2.values()].map((p) => ({
|
|
1069
|
+
...p,
|
|
1070
|
+
metadata: { ...p.metadata },
|
|
1071
|
+
}));
|
|
1072
|
+
}
|
|
1073
|
+
export function createTrustgovCheckV2({
|
|
1074
|
+
id,
|
|
1075
|
+
profileId,
|
|
1076
|
+
subject,
|
|
1077
|
+
metadata,
|
|
1078
|
+
} = {}) {
|
|
1079
|
+
if (!id || !profileId) throw new Error("id and profileId required");
|
|
1080
|
+
if (_trustgovJsV2.has(id))
|
|
1081
|
+
throw new Error(`trustgov check ${id} already exists`);
|
|
1082
|
+
if (!_trustgovPsV2.has(profileId))
|
|
1083
|
+
throw new Error(`trustgov profile ${profileId} not found`);
|
|
1084
|
+
if (_trustgovCountPending(profileId) >= _trustgovMaxPending)
|
|
1085
|
+
throw new Error(
|
|
1086
|
+
`max pending trustgov checks for profile ${profileId} reached`,
|
|
1087
|
+
);
|
|
1088
|
+
const now = Date.now();
|
|
1089
|
+
const j = {
|
|
1090
|
+
id,
|
|
1091
|
+
profileId,
|
|
1092
|
+
subject: subject || "",
|
|
1093
|
+
status: TRUSTGOV_CHECK_LIFECYCLE_V2.QUEUED,
|
|
1094
|
+
createdAt: now,
|
|
1095
|
+
updatedAt: now,
|
|
1096
|
+
startedAt: null,
|
|
1097
|
+
settledAt: null,
|
|
1098
|
+
metadata: { ...(metadata || {}) },
|
|
1099
|
+
};
|
|
1100
|
+
_trustgovJsV2.set(id, j);
|
|
1101
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
1102
|
+
}
|
|
1103
|
+
export function verifyingTrustgovCheckV2(id) {
|
|
1104
|
+
const j = _trustgovJsV2.get(id);
|
|
1105
|
+
if (!j) throw new Error(`trustgov check ${id} not found`);
|
|
1106
|
+
_trustgovCheckJ(j.status, TRUSTGOV_CHECK_LIFECYCLE_V2.VERIFYING);
|
|
1107
|
+
const now = Date.now();
|
|
1108
|
+
j.status = TRUSTGOV_CHECK_LIFECYCLE_V2.VERIFYING;
|
|
1109
|
+
j.updatedAt = now;
|
|
1110
|
+
if (!j.startedAt) j.startedAt = now;
|
|
1111
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
1112
|
+
}
|
|
1113
|
+
export function completeCheckTrustgovV2(id) {
|
|
1114
|
+
const j = _trustgovJsV2.get(id);
|
|
1115
|
+
if (!j) throw new Error(`trustgov check ${id} not found`);
|
|
1116
|
+
_trustgovCheckJ(j.status, TRUSTGOV_CHECK_LIFECYCLE_V2.VERIFIED);
|
|
1117
|
+
const now = Date.now();
|
|
1118
|
+
j.status = TRUSTGOV_CHECK_LIFECYCLE_V2.VERIFIED;
|
|
1119
|
+
j.updatedAt = now;
|
|
1120
|
+
if (!j.settledAt) j.settledAt = now;
|
|
1121
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
1122
|
+
}
|
|
1123
|
+
export function failTrustgovCheckV2(id, reason) {
|
|
1124
|
+
const j = _trustgovJsV2.get(id);
|
|
1125
|
+
if (!j) throw new Error(`trustgov check ${id} not found`);
|
|
1126
|
+
_trustgovCheckJ(j.status, TRUSTGOV_CHECK_LIFECYCLE_V2.FAILED);
|
|
1127
|
+
const now = Date.now();
|
|
1128
|
+
j.status = TRUSTGOV_CHECK_LIFECYCLE_V2.FAILED;
|
|
1129
|
+
j.updatedAt = now;
|
|
1130
|
+
if (!j.settledAt) j.settledAt = now;
|
|
1131
|
+
if (reason) j.metadata.failReason = String(reason);
|
|
1132
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
1133
|
+
}
|
|
1134
|
+
export function cancelTrustgovCheckV2(id, reason) {
|
|
1135
|
+
const j = _trustgovJsV2.get(id);
|
|
1136
|
+
if (!j) throw new Error(`trustgov check ${id} not found`);
|
|
1137
|
+
_trustgovCheckJ(j.status, TRUSTGOV_CHECK_LIFECYCLE_V2.CANCELLED);
|
|
1138
|
+
const now = Date.now();
|
|
1139
|
+
j.status = TRUSTGOV_CHECK_LIFECYCLE_V2.CANCELLED;
|
|
1140
|
+
j.updatedAt = now;
|
|
1141
|
+
if (!j.settledAt) j.settledAt = now;
|
|
1142
|
+
if (reason) j.metadata.cancelReason = String(reason);
|
|
1143
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
1144
|
+
}
|
|
1145
|
+
export function getTrustgovCheckV2(id) {
|
|
1146
|
+
const j = _trustgovJsV2.get(id);
|
|
1147
|
+
if (!j) return null;
|
|
1148
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
1149
|
+
}
|
|
1150
|
+
export function listTrustgovChecksV2() {
|
|
1151
|
+
return [..._trustgovJsV2.values()].map((j) => ({
|
|
1152
|
+
...j,
|
|
1153
|
+
metadata: { ...j.metadata },
|
|
1154
|
+
}));
|
|
1155
|
+
}
|
|
1156
|
+
export function autoSuspendIdleTrustgovProfilesV2({ now } = {}) {
|
|
1157
|
+
const t = now ?? Date.now();
|
|
1158
|
+
const flipped = [];
|
|
1159
|
+
for (const p of _trustgovPsV2.values())
|
|
1160
|
+
if (
|
|
1161
|
+
p.status === TRUSTGOV_PROFILE_MATURITY_V2.ACTIVE &&
|
|
1162
|
+
t - p.lastTouchedAt >= _trustgovIdleMs
|
|
1163
|
+
) {
|
|
1164
|
+
p.status = TRUSTGOV_PROFILE_MATURITY_V2.SUSPENDED;
|
|
1165
|
+
p.updatedAt = t;
|
|
1166
|
+
flipped.push(p.id);
|
|
1167
|
+
}
|
|
1168
|
+
return { flipped, count: flipped.length };
|
|
1169
|
+
}
|
|
1170
|
+
export function autoFailStuckTrustgovChecksV2({ now } = {}) {
|
|
1171
|
+
const t = now ?? Date.now();
|
|
1172
|
+
const flipped = [];
|
|
1173
|
+
for (const j of _trustgovJsV2.values())
|
|
1174
|
+
if (
|
|
1175
|
+
j.status === TRUSTGOV_CHECK_LIFECYCLE_V2.VERIFYING &&
|
|
1176
|
+
j.startedAt != null &&
|
|
1177
|
+
t - j.startedAt >= _trustgovStuckMs
|
|
1178
|
+
) {
|
|
1179
|
+
j.status = TRUSTGOV_CHECK_LIFECYCLE_V2.FAILED;
|
|
1180
|
+
j.updatedAt = t;
|
|
1181
|
+
if (!j.settledAt) j.settledAt = t;
|
|
1182
|
+
j.metadata.failReason = "auto-fail-stuck";
|
|
1183
|
+
flipped.push(j.id);
|
|
1184
|
+
}
|
|
1185
|
+
return { flipped, count: flipped.length };
|
|
1186
|
+
}
|
|
1187
|
+
export function getTrustSecurityGovStatsV2() {
|
|
1188
|
+
const profilesByStatus = {};
|
|
1189
|
+
for (const v of Object.values(TRUSTGOV_PROFILE_MATURITY_V2))
|
|
1190
|
+
profilesByStatus[v] = 0;
|
|
1191
|
+
for (const p of _trustgovPsV2.values()) profilesByStatus[p.status]++;
|
|
1192
|
+
const checksByStatus = {};
|
|
1193
|
+
for (const v of Object.values(TRUSTGOV_CHECK_LIFECYCLE_V2))
|
|
1194
|
+
checksByStatus[v] = 0;
|
|
1195
|
+
for (const j of _trustgovJsV2.values()) checksByStatus[j.status]++;
|
|
1196
|
+
return {
|
|
1197
|
+
totalTrustgovProfilesV2: _trustgovPsV2.size,
|
|
1198
|
+
totalTrustgovChecksV2: _trustgovJsV2.size,
|
|
1199
|
+
maxActiveTrustgovProfilesPerOwner: _trustgovMaxActive,
|
|
1200
|
+
maxPendingTrustgovChecksPerProfile: _trustgovMaxPending,
|
|
1201
|
+
trustgovProfileIdleMs: _trustgovIdleMs,
|
|
1202
|
+
trustgovCheckStuckMs: _trustgovStuckMs,
|
|
1203
|
+
profilesByStatus,
|
|
1204
|
+
checksByStatus,
|
|
1205
|
+
};
|
|
1206
|
+
}
|