chainlesschain 0.132.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 +230 -0
- package/src/commands/activitypub.js +191 -0
- package/src/commands/agent.js +601 -0
- package/src/commands/audit.js +206 -0
- package/src/commands/bi.js +186 -0
- package/src/commands/bm25.js +162 -0
- package/src/commands/browse.js +225 -0
- package/src/commands/ccron.js +178 -0
- package/src/commands/chat.js +207 -0
- package/src/commands/compliance.js +420 -0
- package/src/commands/compt.js +176 -0
- package/src/commands/consol.js +237 -0
- package/src/commands/cowork.js +588 -0
- package/src/commands/crosschain.js +216 -0
- package/src/commands/dao.js +216 -0
- package/src/commands/dlp.js +206 -0
- package/src/commands/economy.js +211 -0
- package/src/commands/evolution.js +209 -0
- package/src/commands/evomap.js +216 -0
- package/src/commands/fflag.js +230 -0
- package/src/commands/git.js +185 -0
- package/src/commands/hardening.js +209 -0
- package/src/commands/hmemory.js +210 -0
- package/src/commands/incentive.js +209 -0
- package/src/commands/inference.js +178 -0
- package/src/commands/itbudget.js +161 -0
- package/src/commands/kg.js +206 -0
- package/src/commands/lowcode.js +201 -0
- package/src/commands/marketplace.js +206 -0
- package/src/commands/matrix.js +214 -0
- package/src/commands/mcpscaf.js +153 -0
- package/src/commands/meminj.js +153 -0
- package/src/commands/nostr.js +213 -0
- package/src/commands/orchestrate.js +217 -0
- package/src/commands/orchgov.js +156 -0
- package/src/commands/pdfp.js +160 -0
- package/src/commands/perf.js +176 -0
- package/src/commands/perm.js +156 -0
- package/src/commands/pipeline.js +211 -0
- package/src/commands/planmode.js +154 -0
- package/src/commands/privacy.js +203 -0
- package/src/commands/promcomp.js +166 -0
- package/src/commands/recommend.js +185 -0
- package/src/commands/reputation.js +208 -0
- package/src/commands/sandbox.js +206 -0
- package/src/commands/seshhook.js +153 -0
- package/src/commands/seshsearch.js +149 -0
- package/src/commands/seshtail.js +152 -0
- package/src/commands/seshu.js +160 -0
- package/src/commands/sganal.js +172 -0
- package/src/commands/siem.js +207 -0
- package/src/commands/sla.js +212 -0
- package/src/commands/slotfill.js +154 -0
- package/src/commands/social.js +159 -0
- package/src/commands/stress.js +206 -0
- package/src/commands/svccont.js +157 -0
- package/src/commands/terraform.js +206 -0
- package/src/commands/tms.js +183 -0
- package/src/commands/topiccls.js +158 -0
- package/src/commands/uprof.js +154 -0
- package/src/commands/vcheck.js +172 -0
- package/src/commands/webfetch.js +150 -0
- package/src/commands/zkp.js +218 -0
- package/src/harness/prompt-compressor.js +331 -0
- package/src/index.js +101 -1
- package/src/lib/a2a-protocol.js +373 -0
- package/src/lib/activitypub-bridge.js +343 -0
- package/src/lib/agent-economy.js +358 -0
- package/src/lib/app-builder.js +338 -0
- package/src/lib/audit-logger.js +321 -0
- package/src/lib/autonomous-agent.js +341 -0
- package/src/lib/bi-engine.js +339 -0
- package/src/lib/bm25-search.js +333 -0
- package/src/lib/browser-automation.js +352 -0
- package/src/lib/chat-core.js +336 -0
- package/src/lib/claude-code-bridge.js +341 -0
- package/src/lib/compliance-framework-reporter.js +359 -0
- package/src/lib/compliance-manager.js +330 -0
- package/src/lib/compression-telemetry.js +333 -0
- package/src/lib/content-recommender.js +370 -0
- package/src/lib/cowork-cron.js +330 -0
- package/src/lib/cowork-learning.js +333 -0
- package/src/lib/cowork-task-runner.js +362 -0
- package/src/lib/cowork-workflow.js +327 -0
- package/src/lib/cross-chain.js +365 -0
- package/src/lib/dao-governance.js +339 -0
- package/src/lib/dlp-engine.js +343 -0
- package/src/lib/evolution-system.js +336 -0
- package/src/lib/evomap-manager.js +339 -0
- package/src/lib/execution-backend.js +351 -0
- package/src/lib/feature-flags.js +330 -0
- package/src/lib/git-integration.js +343 -0
- package/src/lib/hardening-manager.js +341 -0
- package/src/lib/hierarchical-memory.js +341 -0
- package/src/lib/inference-network.js +362 -0
- package/src/lib/iteration-budget.js +357 -0
- package/src/lib/knowledge-graph.js +333 -0
- package/src/lib/matrix-bridge.js +339 -0
- package/src/lib/mcp-scaffold.js +345 -0
- package/src/lib/memory-injection.js +320 -0
- package/src/lib/nostr-bridge.js +342 -0
- package/src/lib/orchestrator.js +350 -0
- package/src/lib/pdf-parser.js +330 -0
- package/src/lib/perf-tuning.js +364 -0
- package/src/lib/permission-engine.js +319 -0
- package/src/lib/pipeline-orchestrator.js +345 -0
- package/src/lib/plan-mode.js +328 -0
- package/src/lib/privacy-computing.js +335 -0
- package/src/lib/prompt-compressor.js +1 -10
- package/src/lib/reputation-optimizer.js +340 -0
- package/src/lib/sandbox-v2.js +327 -0
- package/src/lib/service-container.js +342 -0
- package/src/lib/session-consolidator.js +352 -0
- package/src/lib/session-hooks.js +340 -0
- package/src/lib/session-search.js +334 -0
- package/src/lib/session-tail.js +320 -0
- package/src/lib/session-usage.js +329 -0
- package/src/lib/siem-exporter.js +352 -0
- package/src/lib/skill-marketplace.js +345 -0
- package/src/lib/sla-manager.js +341 -0
- package/src/lib/slot-filler.js +333 -0
- package/src/lib/social-graph-analytics.js +327 -0
- package/src/lib/social-graph.js +304 -0
- package/src/lib/stress-tester.js +342 -0
- package/src/lib/sub-agent-registry.js +359 -0
- package/src/lib/task-model-selector.js +333 -0
- package/src/lib/terraform-manager.js +333 -0
- package/src/lib/todo-manager.js +339 -0
- package/src/lib/token-incentive.js +341 -0
- package/src/lib/topic-classifier.js +353 -0
- package/src/lib/user-profile.js +325 -0
- package/src/lib/version-checker.js +335 -0
- package/src/lib/web-fetch.js +322 -0
- package/src/lib/zkp-engine.js +342 -0
package/src/lib/perf-tuning.js
CHANGED
|
@@ -735,3 +735,367 @@ export function getPerformanceReport(db) {
|
|
|
735
735
|
export function _resetState() {
|
|
736
736
|
/* CLI is stateless; helper exists for parity with other libs */
|
|
737
737
|
}
|
|
738
|
+
|
|
739
|
+
// ===== V2 Surface: Perf Tuning governance overlay (CLI v0.140.0) =====
|
|
740
|
+
export const PERF_TUNING_PROFILE_MATURITY_V2 = Object.freeze({
|
|
741
|
+
PENDING: "pending",
|
|
742
|
+
ACTIVE: "active",
|
|
743
|
+
STALE: "stale",
|
|
744
|
+
DECOMMISSIONED: "decommissioned",
|
|
745
|
+
});
|
|
746
|
+
export const PERF_BENCH_LIFECYCLE_V2 = Object.freeze({
|
|
747
|
+
QUEUED: "queued",
|
|
748
|
+
RUNNING: "running",
|
|
749
|
+
COMPLETED: "completed",
|
|
750
|
+
FAILED: "failed",
|
|
751
|
+
CANCELLED: "cancelled",
|
|
752
|
+
});
|
|
753
|
+
|
|
754
|
+
const _ptpTrans = new Map([
|
|
755
|
+
[
|
|
756
|
+
PERF_TUNING_PROFILE_MATURITY_V2.PENDING,
|
|
757
|
+
new Set([
|
|
758
|
+
PERF_TUNING_PROFILE_MATURITY_V2.ACTIVE,
|
|
759
|
+
PERF_TUNING_PROFILE_MATURITY_V2.DECOMMISSIONED,
|
|
760
|
+
]),
|
|
761
|
+
],
|
|
762
|
+
[
|
|
763
|
+
PERF_TUNING_PROFILE_MATURITY_V2.ACTIVE,
|
|
764
|
+
new Set([
|
|
765
|
+
PERF_TUNING_PROFILE_MATURITY_V2.STALE,
|
|
766
|
+
PERF_TUNING_PROFILE_MATURITY_V2.DECOMMISSIONED,
|
|
767
|
+
]),
|
|
768
|
+
],
|
|
769
|
+
[
|
|
770
|
+
PERF_TUNING_PROFILE_MATURITY_V2.STALE,
|
|
771
|
+
new Set([
|
|
772
|
+
PERF_TUNING_PROFILE_MATURITY_V2.ACTIVE,
|
|
773
|
+
PERF_TUNING_PROFILE_MATURITY_V2.DECOMMISSIONED,
|
|
774
|
+
]),
|
|
775
|
+
],
|
|
776
|
+
[PERF_TUNING_PROFILE_MATURITY_V2.DECOMMISSIONED, new Set()],
|
|
777
|
+
]);
|
|
778
|
+
const _ptpTerminal = new Set([PERF_TUNING_PROFILE_MATURITY_V2.DECOMMISSIONED]);
|
|
779
|
+
const _pbTrans = new Map([
|
|
780
|
+
[
|
|
781
|
+
PERF_BENCH_LIFECYCLE_V2.QUEUED,
|
|
782
|
+
new Set([
|
|
783
|
+
PERF_BENCH_LIFECYCLE_V2.RUNNING,
|
|
784
|
+
PERF_BENCH_LIFECYCLE_V2.CANCELLED,
|
|
785
|
+
]),
|
|
786
|
+
],
|
|
787
|
+
[
|
|
788
|
+
PERF_BENCH_LIFECYCLE_V2.RUNNING,
|
|
789
|
+
new Set([
|
|
790
|
+
PERF_BENCH_LIFECYCLE_V2.COMPLETED,
|
|
791
|
+
PERF_BENCH_LIFECYCLE_V2.FAILED,
|
|
792
|
+
PERF_BENCH_LIFECYCLE_V2.CANCELLED,
|
|
793
|
+
]),
|
|
794
|
+
],
|
|
795
|
+
[PERF_BENCH_LIFECYCLE_V2.COMPLETED, new Set()],
|
|
796
|
+
[PERF_BENCH_LIFECYCLE_V2.FAILED, new Set()],
|
|
797
|
+
[PERF_BENCH_LIFECYCLE_V2.CANCELLED, new Set()],
|
|
798
|
+
]);
|
|
799
|
+
|
|
800
|
+
const _ptpsV2 = new Map();
|
|
801
|
+
const _pbsV2 = new Map();
|
|
802
|
+
let _ptpMaxActivePerOwner = 6;
|
|
803
|
+
let _ptpMaxPendingBenchesPerProfile = 10;
|
|
804
|
+
let _ptpIdleMs = 7 * 24 * 60 * 60 * 1000;
|
|
805
|
+
let _pbStuckMs = 30 * 60 * 1000;
|
|
806
|
+
|
|
807
|
+
function _ptpPos(n, lbl) {
|
|
808
|
+
const v = Math.floor(Number(n));
|
|
809
|
+
if (!Number.isFinite(v) || v <= 0)
|
|
810
|
+
throw new Error(`${lbl} must be positive integer`);
|
|
811
|
+
return v;
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
export function setMaxActivePerfTuningProfilesPerOwnerV2(n) {
|
|
815
|
+
_ptpMaxActivePerOwner = _ptpPos(n, "maxActivePerfTuningProfilesPerOwner");
|
|
816
|
+
}
|
|
817
|
+
export function getMaxActivePerfTuningProfilesPerOwnerV2() {
|
|
818
|
+
return _ptpMaxActivePerOwner;
|
|
819
|
+
}
|
|
820
|
+
export function setMaxPendingPerfBenchesPerProfileV2(n) {
|
|
821
|
+
_ptpMaxPendingBenchesPerProfile = _ptpPos(
|
|
822
|
+
n,
|
|
823
|
+
"maxPendingPerfBenchesPerProfile",
|
|
824
|
+
);
|
|
825
|
+
}
|
|
826
|
+
export function getMaxPendingPerfBenchesPerProfileV2() {
|
|
827
|
+
return _ptpMaxPendingBenchesPerProfile;
|
|
828
|
+
}
|
|
829
|
+
export function setPerfTuningProfileIdleMsV2(n) {
|
|
830
|
+
_ptpIdleMs = _ptpPos(n, "perfTuningProfileIdleMs");
|
|
831
|
+
}
|
|
832
|
+
export function getPerfTuningProfileIdleMsV2() {
|
|
833
|
+
return _ptpIdleMs;
|
|
834
|
+
}
|
|
835
|
+
export function setPerfBenchStuckMsV2(n) {
|
|
836
|
+
_pbStuckMs = _ptpPos(n, "perfBenchStuckMs");
|
|
837
|
+
}
|
|
838
|
+
export function getPerfBenchStuckMsV2() {
|
|
839
|
+
return _pbStuckMs;
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
export function _resetStatePerfTuningV2() {
|
|
843
|
+
_ptpsV2.clear();
|
|
844
|
+
_pbsV2.clear();
|
|
845
|
+
_ptpMaxActivePerOwner = 6;
|
|
846
|
+
_ptpMaxPendingBenchesPerProfile = 10;
|
|
847
|
+
_ptpIdleMs = 7 * 24 * 60 * 60 * 1000;
|
|
848
|
+
_pbStuckMs = 30 * 60 * 1000;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
export function registerPerfTuningProfileV2({
|
|
852
|
+
id,
|
|
853
|
+
owner,
|
|
854
|
+
target,
|
|
855
|
+
metadata,
|
|
856
|
+
} = {}) {
|
|
857
|
+
if (!id || typeof id !== "string") throw new Error("id is required");
|
|
858
|
+
if (!owner || typeof owner !== "string") throw new Error("owner is required");
|
|
859
|
+
if (_ptpsV2.has(id))
|
|
860
|
+
throw new Error(`perf tuning profile ${id} already registered`);
|
|
861
|
+
const now = Date.now();
|
|
862
|
+
const p = {
|
|
863
|
+
id,
|
|
864
|
+
owner,
|
|
865
|
+
target: target || "default",
|
|
866
|
+
status: PERF_TUNING_PROFILE_MATURITY_V2.PENDING,
|
|
867
|
+
createdAt: now,
|
|
868
|
+
updatedAt: now,
|
|
869
|
+
activatedAt: null,
|
|
870
|
+
decommissionedAt: null,
|
|
871
|
+
lastTouchedAt: now,
|
|
872
|
+
metadata: { ...(metadata || {}) },
|
|
873
|
+
};
|
|
874
|
+
_ptpsV2.set(id, p);
|
|
875
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
876
|
+
}
|
|
877
|
+
function _ptpCheckP(from, to) {
|
|
878
|
+
const a = _ptpTrans.get(from);
|
|
879
|
+
if (!a || !a.has(to))
|
|
880
|
+
throw new Error(`invalid perf tuning profile transition ${from} → ${to}`);
|
|
881
|
+
}
|
|
882
|
+
function _ptpCountActive(owner) {
|
|
883
|
+
let n = 0;
|
|
884
|
+
for (const p of _ptpsV2.values())
|
|
885
|
+
if (
|
|
886
|
+
p.owner === owner &&
|
|
887
|
+
p.status === PERF_TUNING_PROFILE_MATURITY_V2.ACTIVE
|
|
888
|
+
)
|
|
889
|
+
n++;
|
|
890
|
+
return n;
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
export function activatePerfTuningProfileV2(id) {
|
|
894
|
+
const p = _ptpsV2.get(id);
|
|
895
|
+
if (!p) throw new Error(`perf tuning profile ${id} not found`);
|
|
896
|
+
_ptpCheckP(p.status, PERF_TUNING_PROFILE_MATURITY_V2.ACTIVE);
|
|
897
|
+
const recovery = p.status === PERF_TUNING_PROFILE_MATURITY_V2.STALE;
|
|
898
|
+
if (!recovery) {
|
|
899
|
+
const c = _ptpCountActive(p.owner);
|
|
900
|
+
if (c >= _ptpMaxActivePerOwner)
|
|
901
|
+
throw new Error(
|
|
902
|
+
`max active perf tuning profiles per owner (${_ptpMaxActivePerOwner}) reached for ${p.owner}`,
|
|
903
|
+
);
|
|
904
|
+
}
|
|
905
|
+
const now = Date.now();
|
|
906
|
+
p.status = PERF_TUNING_PROFILE_MATURITY_V2.ACTIVE;
|
|
907
|
+
p.updatedAt = now;
|
|
908
|
+
p.lastTouchedAt = now;
|
|
909
|
+
if (!p.activatedAt) p.activatedAt = now;
|
|
910
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
911
|
+
}
|
|
912
|
+
export function stalePerfTuningProfileV2(id) {
|
|
913
|
+
const p = _ptpsV2.get(id);
|
|
914
|
+
if (!p) throw new Error(`perf tuning profile ${id} not found`);
|
|
915
|
+
_ptpCheckP(p.status, PERF_TUNING_PROFILE_MATURITY_V2.STALE);
|
|
916
|
+
p.status = PERF_TUNING_PROFILE_MATURITY_V2.STALE;
|
|
917
|
+
p.updatedAt = Date.now();
|
|
918
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
919
|
+
}
|
|
920
|
+
export function decommissionPerfTuningProfileV2(id) {
|
|
921
|
+
const p = _ptpsV2.get(id);
|
|
922
|
+
if (!p) throw new Error(`perf tuning profile ${id} not found`);
|
|
923
|
+
_ptpCheckP(p.status, PERF_TUNING_PROFILE_MATURITY_V2.DECOMMISSIONED);
|
|
924
|
+
const now = Date.now();
|
|
925
|
+
p.status = PERF_TUNING_PROFILE_MATURITY_V2.DECOMMISSIONED;
|
|
926
|
+
p.updatedAt = now;
|
|
927
|
+
if (!p.decommissionedAt) p.decommissionedAt = now;
|
|
928
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
929
|
+
}
|
|
930
|
+
export function touchPerfTuningProfileV2(id) {
|
|
931
|
+
const p = _ptpsV2.get(id);
|
|
932
|
+
if (!p) throw new Error(`perf tuning profile ${id} not found`);
|
|
933
|
+
if (_ptpTerminal.has(p.status))
|
|
934
|
+
throw new Error(`cannot touch terminal perf tuning profile ${id}`);
|
|
935
|
+
const now = Date.now();
|
|
936
|
+
p.lastTouchedAt = now;
|
|
937
|
+
p.updatedAt = now;
|
|
938
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
939
|
+
}
|
|
940
|
+
export function getPerfTuningProfileV2(id) {
|
|
941
|
+
const p = _ptpsV2.get(id);
|
|
942
|
+
if (!p) return null;
|
|
943
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
944
|
+
}
|
|
945
|
+
export function listPerfTuningProfilesV2() {
|
|
946
|
+
return [..._ptpsV2.values()].map((p) => ({
|
|
947
|
+
...p,
|
|
948
|
+
metadata: { ...p.metadata },
|
|
949
|
+
}));
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
function _pbCountPending(profileId) {
|
|
953
|
+
let n = 0;
|
|
954
|
+
for (const b of _pbsV2.values())
|
|
955
|
+
if (
|
|
956
|
+
b.profileId === profileId &&
|
|
957
|
+
(b.status === PERF_BENCH_LIFECYCLE_V2.QUEUED ||
|
|
958
|
+
b.status === PERF_BENCH_LIFECYCLE_V2.RUNNING)
|
|
959
|
+
)
|
|
960
|
+
n++;
|
|
961
|
+
return n;
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
export function createPerfBenchV2({ id, profileId, scenario, metadata } = {}) {
|
|
965
|
+
if (!id || typeof id !== "string") throw new Error("id is required");
|
|
966
|
+
if (!profileId || typeof profileId !== "string")
|
|
967
|
+
throw new Error("profileId is required");
|
|
968
|
+
if (_pbsV2.has(id)) throw new Error(`perf bench ${id} already exists`);
|
|
969
|
+
if (!_ptpsV2.has(profileId))
|
|
970
|
+
throw new Error(`perf tuning profile ${profileId} not found`);
|
|
971
|
+
const pending = _pbCountPending(profileId);
|
|
972
|
+
if (pending >= _ptpMaxPendingBenchesPerProfile)
|
|
973
|
+
throw new Error(
|
|
974
|
+
`max pending perf benches per profile (${_ptpMaxPendingBenchesPerProfile}) reached for ${profileId}`,
|
|
975
|
+
);
|
|
976
|
+
const now = Date.now();
|
|
977
|
+
const b = {
|
|
978
|
+
id,
|
|
979
|
+
profileId,
|
|
980
|
+
scenario: scenario || "",
|
|
981
|
+
status: PERF_BENCH_LIFECYCLE_V2.QUEUED,
|
|
982
|
+
createdAt: now,
|
|
983
|
+
updatedAt: now,
|
|
984
|
+
startedAt: null,
|
|
985
|
+
settledAt: null,
|
|
986
|
+
metadata: { ...(metadata || {}) },
|
|
987
|
+
};
|
|
988
|
+
_pbsV2.set(id, b);
|
|
989
|
+
return { ...b, metadata: { ...b.metadata } };
|
|
990
|
+
}
|
|
991
|
+
function _pbCheckB(from, to) {
|
|
992
|
+
const a = _pbTrans.get(from);
|
|
993
|
+
if (!a || !a.has(to))
|
|
994
|
+
throw new Error(`invalid perf bench transition ${from} → ${to}`);
|
|
995
|
+
}
|
|
996
|
+
export function startPerfBenchV2(id) {
|
|
997
|
+
const b = _pbsV2.get(id);
|
|
998
|
+
if (!b) throw new Error(`perf bench ${id} not found`);
|
|
999
|
+
_pbCheckB(b.status, PERF_BENCH_LIFECYCLE_V2.RUNNING);
|
|
1000
|
+
const now = Date.now();
|
|
1001
|
+
b.status = PERF_BENCH_LIFECYCLE_V2.RUNNING;
|
|
1002
|
+
b.updatedAt = now;
|
|
1003
|
+
if (!b.startedAt) b.startedAt = now;
|
|
1004
|
+
return { ...b, metadata: { ...b.metadata } };
|
|
1005
|
+
}
|
|
1006
|
+
export function completePerfBenchV2(id) {
|
|
1007
|
+
const b = _pbsV2.get(id);
|
|
1008
|
+
if (!b) throw new Error(`perf bench ${id} not found`);
|
|
1009
|
+
_pbCheckB(b.status, PERF_BENCH_LIFECYCLE_V2.COMPLETED);
|
|
1010
|
+
const now = Date.now();
|
|
1011
|
+
b.status = PERF_BENCH_LIFECYCLE_V2.COMPLETED;
|
|
1012
|
+
b.updatedAt = now;
|
|
1013
|
+
if (!b.settledAt) b.settledAt = now;
|
|
1014
|
+
return { ...b, metadata: { ...b.metadata } };
|
|
1015
|
+
}
|
|
1016
|
+
export function failPerfBenchV2(id, reason) {
|
|
1017
|
+
const b = _pbsV2.get(id);
|
|
1018
|
+
if (!b) throw new Error(`perf bench ${id} not found`);
|
|
1019
|
+
_pbCheckB(b.status, PERF_BENCH_LIFECYCLE_V2.FAILED);
|
|
1020
|
+
const now = Date.now();
|
|
1021
|
+
b.status = PERF_BENCH_LIFECYCLE_V2.FAILED;
|
|
1022
|
+
b.updatedAt = now;
|
|
1023
|
+
if (!b.settledAt) b.settledAt = now;
|
|
1024
|
+
if (reason) b.metadata.failReason = String(reason);
|
|
1025
|
+
return { ...b, metadata: { ...b.metadata } };
|
|
1026
|
+
}
|
|
1027
|
+
export function cancelPerfBenchV2(id, reason) {
|
|
1028
|
+
const b = _pbsV2.get(id);
|
|
1029
|
+
if (!b) throw new Error(`perf bench ${id} not found`);
|
|
1030
|
+
_pbCheckB(b.status, PERF_BENCH_LIFECYCLE_V2.CANCELLED);
|
|
1031
|
+
const now = Date.now();
|
|
1032
|
+
b.status = PERF_BENCH_LIFECYCLE_V2.CANCELLED;
|
|
1033
|
+
b.updatedAt = now;
|
|
1034
|
+
if (!b.settledAt) b.settledAt = now;
|
|
1035
|
+
if (reason) b.metadata.cancelReason = String(reason);
|
|
1036
|
+
return { ...b, metadata: { ...b.metadata } };
|
|
1037
|
+
}
|
|
1038
|
+
export function getPerfBenchV2(id) {
|
|
1039
|
+
const b = _pbsV2.get(id);
|
|
1040
|
+
if (!b) return null;
|
|
1041
|
+
return { ...b, metadata: { ...b.metadata } };
|
|
1042
|
+
}
|
|
1043
|
+
export function listPerfBenchesV2() {
|
|
1044
|
+
return [..._pbsV2.values()].map((b) => ({
|
|
1045
|
+
...b,
|
|
1046
|
+
metadata: { ...b.metadata },
|
|
1047
|
+
}));
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
export function autoStaleIdlePerfTuningProfilesV2({ now } = {}) {
|
|
1051
|
+
const t = now ?? Date.now();
|
|
1052
|
+
const flipped = [];
|
|
1053
|
+
for (const p of _ptpsV2.values())
|
|
1054
|
+
if (
|
|
1055
|
+
p.status === PERF_TUNING_PROFILE_MATURITY_V2.ACTIVE &&
|
|
1056
|
+
t - p.lastTouchedAt >= _ptpIdleMs
|
|
1057
|
+
) {
|
|
1058
|
+
p.status = PERF_TUNING_PROFILE_MATURITY_V2.STALE;
|
|
1059
|
+
p.updatedAt = t;
|
|
1060
|
+
flipped.push(p.id);
|
|
1061
|
+
}
|
|
1062
|
+
return { flipped, count: flipped.length };
|
|
1063
|
+
}
|
|
1064
|
+
export function autoFailStuckPerfBenchesV2({ now } = {}) {
|
|
1065
|
+
const t = now ?? Date.now();
|
|
1066
|
+
const flipped = [];
|
|
1067
|
+
for (const b of _pbsV2.values())
|
|
1068
|
+
if (
|
|
1069
|
+
b.status === PERF_BENCH_LIFECYCLE_V2.RUNNING &&
|
|
1070
|
+
b.startedAt != null &&
|
|
1071
|
+
t - b.startedAt >= _pbStuckMs
|
|
1072
|
+
) {
|
|
1073
|
+
b.status = PERF_BENCH_LIFECYCLE_V2.FAILED;
|
|
1074
|
+
b.updatedAt = t;
|
|
1075
|
+
if (!b.settledAt) b.settledAt = t;
|
|
1076
|
+
b.metadata.failReason = "auto-fail-stuck";
|
|
1077
|
+
flipped.push(b.id);
|
|
1078
|
+
}
|
|
1079
|
+
return { flipped, count: flipped.length };
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
export function getPerfTuningGovStatsV2() {
|
|
1083
|
+
const profilesByStatus = {};
|
|
1084
|
+
for (const s of Object.values(PERF_TUNING_PROFILE_MATURITY_V2))
|
|
1085
|
+
profilesByStatus[s] = 0;
|
|
1086
|
+
for (const p of _ptpsV2.values()) profilesByStatus[p.status]++;
|
|
1087
|
+
const benchesByStatus = {};
|
|
1088
|
+
for (const s of Object.values(PERF_BENCH_LIFECYCLE_V2))
|
|
1089
|
+
benchesByStatus[s] = 0;
|
|
1090
|
+
for (const b of _pbsV2.values()) benchesByStatus[b.status]++;
|
|
1091
|
+
return {
|
|
1092
|
+
totalPerfTuningProfilesV2: _ptpsV2.size,
|
|
1093
|
+
totalPerfBenchesV2: _pbsV2.size,
|
|
1094
|
+
maxActivePerfTuningProfilesPerOwner: _ptpMaxActivePerOwner,
|
|
1095
|
+
maxPendingPerfBenchesPerProfile: _ptpMaxPendingBenchesPerProfile,
|
|
1096
|
+
perfTuningProfileIdleMs: _ptpIdleMs,
|
|
1097
|
+
perfBenchStuckMs: _pbStuckMs,
|
|
1098
|
+
profilesByStatus,
|
|
1099
|
+
benchesByStatus,
|
|
1100
|
+
};
|
|
1101
|
+
}
|
|
@@ -372,3 +372,322 @@ export function listUserRoles(db) {
|
|
|
372
372
|
|
|
373
373
|
return [...userMap.entries()].map(([userDid, roles]) => ({ userDid, roles }));
|
|
374
374
|
}
|
|
375
|
+
|
|
376
|
+
// ===== V2 Surface: Permission Engine governance overlay (CLI v0.141.0) =====
|
|
377
|
+
export const PERM_RULE_MATURITY_V2 = Object.freeze({
|
|
378
|
+
PENDING: "pending",
|
|
379
|
+
ACTIVE: "active",
|
|
380
|
+
DISABLED: "disabled",
|
|
381
|
+
RETIRED: "retired",
|
|
382
|
+
});
|
|
383
|
+
export const PERM_CHECK_LIFECYCLE_V2 = Object.freeze({
|
|
384
|
+
QUEUED: "queued",
|
|
385
|
+
EVALUATING: "evaluating",
|
|
386
|
+
ALLOWED: "allowed",
|
|
387
|
+
DENIED: "denied",
|
|
388
|
+
CANCELLED: "cancelled",
|
|
389
|
+
});
|
|
390
|
+
const _permRTrans = new Map([
|
|
391
|
+
[
|
|
392
|
+
PERM_RULE_MATURITY_V2.PENDING,
|
|
393
|
+
new Set([PERM_RULE_MATURITY_V2.ACTIVE, PERM_RULE_MATURITY_V2.RETIRED]),
|
|
394
|
+
],
|
|
395
|
+
[
|
|
396
|
+
PERM_RULE_MATURITY_V2.ACTIVE,
|
|
397
|
+
new Set([PERM_RULE_MATURITY_V2.DISABLED, PERM_RULE_MATURITY_V2.RETIRED]),
|
|
398
|
+
],
|
|
399
|
+
[
|
|
400
|
+
PERM_RULE_MATURITY_V2.DISABLED,
|
|
401
|
+
new Set([PERM_RULE_MATURITY_V2.ACTIVE, PERM_RULE_MATURITY_V2.RETIRED]),
|
|
402
|
+
],
|
|
403
|
+
[PERM_RULE_MATURITY_V2.RETIRED, new Set()],
|
|
404
|
+
]);
|
|
405
|
+
const _permRTerminal = new Set([PERM_RULE_MATURITY_V2.RETIRED]);
|
|
406
|
+
const _permCTrans = new Map([
|
|
407
|
+
[
|
|
408
|
+
PERM_CHECK_LIFECYCLE_V2.QUEUED,
|
|
409
|
+
new Set([
|
|
410
|
+
PERM_CHECK_LIFECYCLE_V2.EVALUATING,
|
|
411
|
+
PERM_CHECK_LIFECYCLE_V2.CANCELLED,
|
|
412
|
+
]),
|
|
413
|
+
],
|
|
414
|
+
[
|
|
415
|
+
PERM_CHECK_LIFECYCLE_V2.EVALUATING,
|
|
416
|
+
new Set([
|
|
417
|
+
PERM_CHECK_LIFECYCLE_V2.ALLOWED,
|
|
418
|
+
PERM_CHECK_LIFECYCLE_V2.DENIED,
|
|
419
|
+
PERM_CHECK_LIFECYCLE_V2.CANCELLED,
|
|
420
|
+
]),
|
|
421
|
+
],
|
|
422
|
+
[PERM_CHECK_LIFECYCLE_V2.ALLOWED, new Set()],
|
|
423
|
+
[PERM_CHECK_LIFECYCLE_V2.DENIED, new Set()],
|
|
424
|
+
[PERM_CHECK_LIFECYCLE_V2.CANCELLED, new Set()],
|
|
425
|
+
]);
|
|
426
|
+
const _permRsV2 = new Map();
|
|
427
|
+
const _permCsV2 = new Map();
|
|
428
|
+
let _permMaxActivePerOwner = 10,
|
|
429
|
+
_permMaxPendingChecksPerRule = 30,
|
|
430
|
+
_permIdleMs = 30 * 24 * 60 * 60 * 1000,
|
|
431
|
+
_permStuckMs = 60 * 1000;
|
|
432
|
+
function _permPos(n, label) {
|
|
433
|
+
const v = Math.floor(Number(n));
|
|
434
|
+
if (!Number.isFinite(v) || v <= 0)
|
|
435
|
+
throw new Error(`${label} must be positive integer`);
|
|
436
|
+
return v;
|
|
437
|
+
}
|
|
438
|
+
function _permCheckR(from, to) {
|
|
439
|
+
const a = _permRTrans.get(from);
|
|
440
|
+
if (!a || !a.has(to))
|
|
441
|
+
throw new Error(`invalid perm rule transition ${from} → ${to}`);
|
|
442
|
+
}
|
|
443
|
+
function _permCheckC(from, to) {
|
|
444
|
+
const a = _permCTrans.get(from);
|
|
445
|
+
if (!a || !a.has(to))
|
|
446
|
+
throw new Error(`invalid perm check transition ${from} → ${to}`);
|
|
447
|
+
}
|
|
448
|
+
export function setMaxActivePermRulesPerOwnerV2(n) {
|
|
449
|
+
_permMaxActivePerOwner = _permPos(n, "maxActivePermRulesPerOwner");
|
|
450
|
+
}
|
|
451
|
+
export function getMaxActivePermRulesPerOwnerV2() {
|
|
452
|
+
return _permMaxActivePerOwner;
|
|
453
|
+
}
|
|
454
|
+
export function setMaxPendingPermChecksPerRuleV2(n) {
|
|
455
|
+
_permMaxPendingChecksPerRule = _permPos(n, "maxPendingPermChecksPerRule");
|
|
456
|
+
}
|
|
457
|
+
export function getMaxPendingPermChecksPerRuleV2() {
|
|
458
|
+
return _permMaxPendingChecksPerRule;
|
|
459
|
+
}
|
|
460
|
+
export function setPermRuleIdleMsV2(n) {
|
|
461
|
+
_permIdleMs = _permPos(n, "permRuleIdleMs");
|
|
462
|
+
}
|
|
463
|
+
export function getPermRuleIdleMsV2() {
|
|
464
|
+
return _permIdleMs;
|
|
465
|
+
}
|
|
466
|
+
export function setPermCheckStuckMsV2(n) {
|
|
467
|
+
_permStuckMs = _permPos(n, "permCheckStuckMs");
|
|
468
|
+
}
|
|
469
|
+
export function getPermCheckStuckMsV2() {
|
|
470
|
+
return _permStuckMs;
|
|
471
|
+
}
|
|
472
|
+
export function _resetStatePermissionEngineV2() {
|
|
473
|
+
_permRsV2.clear();
|
|
474
|
+
_permCsV2.clear();
|
|
475
|
+
_permMaxActivePerOwner = 10;
|
|
476
|
+
_permMaxPendingChecksPerRule = 30;
|
|
477
|
+
_permIdleMs = 30 * 24 * 60 * 60 * 1000;
|
|
478
|
+
_permStuckMs = 60 * 1000;
|
|
479
|
+
}
|
|
480
|
+
export function registerPermRuleV2({ id, owner, scope, metadata } = {}) {
|
|
481
|
+
if (!id) throw new Error("perm rule id required");
|
|
482
|
+
if (!owner) throw new Error("perm rule owner required");
|
|
483
|
+
if (_permRsV2.has(id)) throw new Error(`perm rule ${id} already registered`);
|
|
484
|
+
const now = Date.now();
|
|
485
|
+
const r = {
|
|
486
|
+
id,
|
|
487
|
+
owner,
|
|
488
|
+
scope: scope || "*",
|
|
489
|
+
status: PERM_RULE_MATURITY_V2.PENDING,
|
|
490
|
+
createdAt: now,
|
|
491
|
+
updatedAt: now,
|
|
492
|
+
activatedAt: null,
|
|
493
|
+
retiredAt: null,
|
|
494
|
+
lastTouchedAt: now,
|
|
495
|
+
metadata: { ...(metadata || {}) },
|
|
496
|
+
};
|
|
497
|
+
_permRsV2.set(id, r);
|
|
498
|
+
return { ...r, metadata: { ...r.metadata } };
|
|
499
|
+
}
|
|
500
|
+
function _permCountActive(owner) {
|
|
501
|
+
let n = 0;
|
|
502
|
+
for (const r of _permRsV2.values())
|
|
503
|
+
if (r.owner === owner && r.status === PERM_RULE_MATURITY_V2.ACTIVE) n++;
|
|
504
|
+
return n;
|
|
505
|
+
}
|
|
506
|
+
export function activatePermRuleV2(id) {
|
|
507
|
+
const r = _permRsV2.get(id);
|
|
508
|
+
if (!r) throw new Error(`perm rule ${id} not found`);
|
|
509
|
+
_permCheckR(r.status, PERM_RULE_MATURITY_V2.ACTIVE);
|
|
510
|
+
const recovery = r.status === PERM_RULE_MATURITY_V2.DISABLED;
|
|
511
|
+
if (!recovery && _permCountActive(r.owner) >= _permMaxActivePerOwner)
|
|
512
|
+
throw new Error(`max active perm rules for owner ${r.owner} reached`);
|
|
513
|
+
const now = Date.now();
|
|
514
|
+
r.status = PERM_RULE_MATURITY_V2.ACTIVE;
|
|
515
|
+
r.updatedAt = now;
|
|
516
|
+
r.lastTouchedAt = now;
|
|
517
|
+
if (!r.activatedAt) r.activatedAt = now;
|
|
518
|
+
return { ...r, metadata: { ...r.metadata } };
|
|
519
|
+
}
|
|
520
|
+
export function disablePermRuleV2(id) {
|
|
521
|
+
const r = _permRsV2.get(id);
|
|
522
|
+
if (!r) throw new Error(`perm rule ${id} not found`);
|
|
523
|
+
_permCheckR(r.status, PERM_RULE_MATURITY_V2.DISABLED);
|
|
524
|
+
r.status = PERM_RULE_MATURITY_V2.DISABLED;
|
|
525
|
+
r.updatedAt = Date.now();
|
|
526
|
+
return { ...r, metadata: { ...r.metadata } };
|
|
527
|
+
}
|
|
528
|
+
export function retirePermRuleV2(id) {
|
|
529
|
+
const r = _permRsV2.get(id);
|
|
530
|
+
if (!r) throw new Error(`perm rule ${id} not found`);
|
|
531
|
+
_permCheckR(r.status, PERM_RULE_MATURITY_V2.RETIRED);
|
|
532
|
+
const now = Date.now();
|
|
533
|
+
r.status = PERM_RULE_MATURITY_V2.RETIRED;
|
|
534
|
+
r.updatedAt = now;
|
|
535
|
+
if (!r.retiredAt) r.retiredAt = now;
|
|
536
|
+
return { ...r, metadata: { ...r.metadata } };
|
|
537
|
+
}
|
|
538
|
+
export function touchPermRuleV2(id) {
|
|
539
|
+
const r = _permRsV2.get(id);
|
|
540
|
+
if (!r) throw new Error(`perm rule ${id} not found`);
|
|
541
|
+
if (_permRTerminal.has(r.status))
|
|
542
|
+
throw new Error(`cannot touch terminal perm rule ${id}`);
|
|
543
|
+
const now = Date.now();
|
|
544
|
+
r.lastTouchedAt = now;
|
|
545
|
+
r.updatedAt = now;
|
|
546
|
+
return { ...r, metadata: { ...r.metadata } };
|
|
547
|
+
}
|
|
548
|
+
export function getPermRuleV2(id) {
|
|
549
|
+
const r = _permRsV2.get(id);
|
|
550
|
+
if (!r) return null;
|
|
551
|
+
return { ...r, metadata: { ...r.metadata } };
|
|
552
|
+
}
|
|
553
|
+
export function listPermRulesV2() {
|
|
554
|
+
return [..._permRsV2.values()].map((r) => ({
|
|
555
|
+
...r,
|
|
556
|
+
metadata: { ...r.metadata },
|
|
557
|
+
}));
|
|
558
|
+
}
|
|
559
|
+
function _permCountPending(ruleId) {
|
|
560
|
+
let n = 0;
|
|
561
|
+
for (const c of _permCsV2.values())
|
|
562
|
+
if (
|
|
563
|
+
c.ruleId === ruleId &&
|
|
564
|
+
(c.status === PERM_CHECK_LIFECYCLE_V2.QUEUED ||
|
|
565
|
+
c.status === PERM_CHECK_LIFECYCLE_V2.EVALUATING)
|
|
566
|
+
)
|
|
567
|
+
n++;
|
|
568
|
+
return n;
|
|
569
|
+
}
|
|
570
|
+
export function createPermCheckV2({ id, ruleId, subject, metadata } = {}) {
|
|
571
|
+
if (!id) throw new Error("perm check id required");
|
|
572
|
+
if (!ruleId) throw new Error("perm check ruleId required");
|
|
573
|
+
if (_permCsV2.has(id)) throw new Error(`perm check ${id} already exists`);
|
|
574
|
+
if (!_permRsV2.has(ruleId)) throw new Error(`perm rule ${ruleId} not found`);
|
|
575
|
+
if (_permCountPending(ruleId) >= _permMaxPendingChecksPerRule)
|
|
576
|
+
throw new Error(`max pending perm checks for rule ${ruleId} reached`);
|
|
577
|
+
const now = Date.now();
|
|
578
|
+
const c = {
|
|
579
|
+
id,
|
|
580
|
+
ruleId,
|
|
581
|
+
subject: subject || "",
|
|
582
|
+
status: PERM_CHECK_LIFECYCLE_V2.QUEUED,
|
|
583
|
+
createdAt: now,
|
|
584
|
+
updatedAt: now,
|
|
585
|
+
startedAt: null,
|
|
586
|
+
settledAt: null,
|
|
587
|
+
metadata: { ...(metadata || {}) },
|
|
588
|
+
};
|
|
589
|
+
_permCsV2.set(id, c);
|
|
590
|
+
return { ...c, metadata: { ...c.metadata } };
|
|
591
|
+
}
|
|
592
|
+
export function evaluatePermCheckV2(id) {
|
|
593
|
+
const c = _permCsV2.get(id);
|
|
594
|
+
if (!c) throw new Error(`perm check ${id} not found`);
|
|
595
|
+
_permCheckC(c.status, PERM_CHECK_LIFECYCLE_V2.EVALUATING);
|
|
596
|
+
const now = Date.now();
|
|
597
|
+
c.status = PERM_CHECK_LIFECYCLE_V2.EVALUATING;
|
|
598
|
+
c.updatedAt = now;
|
|
599
|
+
if (!c.startedAt) c.startedAt = now;
|
|
600
|
+
return { ...c, metadata: { ...c.metadata } };
|
|
601
|
+
}
|
|
602
|
+
export function allowPermCheckV2(id) {
|
|
603
|
+
const c = _permCsV2.get(id);
|
|
604
|
+
if (!c) throw new Error(`perm check ${id} not found`);
|
|
605
|
+
_permCheckC(c.status, PERM_CHECK_LIFECYCLE_V2.ALLOWED);
|
|
606
|
+
const now = Date.now();
|
|
607
|
+
c.status = PERM_CHECK_LIFECYCLE_V2.ALLOWED;
|
|
608
|
+
c.updatedAt = now;
|
|
609
|
+
if (!c.settledAt) c.settledAt = now;
|
|
610
|
+
return { ...c, metadata: { ...c.metadata } };
|
|
611
|
+
}
|
|
612
|
+
export function denyPermCheckV2(id, reason) {
|
|
613
|
+
const c = _permCsV2.get(id);
|
|
614
|
+
if (!c) throw new Error(`perm check ${id} not found`);
|
|
615
|
+
_permCheckC(c.status, PERM_CHECK_LIFECYCLE_V2.DENIED);
|
|
616
|
+
const now = Date.now();
|
|
617
|
+
c.status = PERM_CHECK_LIFECYCLE_V2.DENIED;
|
|
618
|
+
c.updatedAt = now;
|
|
619
|
+
if (!c.settledAt) c.settledAt = now;
|
|
620
|
+
if (reason) c.metadata.denyReason = String(reason);
|
|
621
|
+
return { ...c, metadata: { ...c.metadata } };
|
|
622
|
+
}
|
|
623
|
+
export function cancelPermCheckV2(id, reason) {
|
|
624
|
+
const c = _permCsV2.get(id);
|
|
625
|
+
if (!c) throw new Error(`perm check ${id} not found`);
|
|
626
|
+
_permCheckC(c.status, PERM_CHECK_LIFECYCLE_V2.CANCELLED);
|
|
627
|
+
const now = Date.now();
|
|
628
|
+
c.status = PERM_CHECK_LIFECYCLE_V2.CANCELLED;
|
|
629
|
+
c.updatedAt = now;
|
|
630
|
+
if (!c.settledAt) c.settledAt = now;
|
|
631
|
+
if (reason) c.metadata.cancelReason = String(reason);
|
|
632
|
+
return { ...c, metadata: { ...c.metadata } };
|
|
633
|
+
}
|
|
634
|
+
export function getPermCheckV2(id) {
|
|
635
|
+
const c = _permCsV2.get(id);
|
|
636
|
+
if (!c) return null;
|
|
637
|
+
return { ...c, metadata: { ...c.metadata } };
|
|
638
|
+
}
|
|
639
|
+
export function listPermChecksV2() {
|
|
640
|
+
return [..._permCsV2.values()].map((c) => ({
|
|
641
|
+
...c,
|
|
642
|
+
metadata: { ...c.metadata },
|
|
643
|
+
}));
|
|
644
|
+
}
|
|
645
|
+
export function autoDisableIdlePermRulesV2({ now } = {}) {
|
|
646
|
+
const t = now ?? Date.now();
|
|
647
|
+
const flipped = [];
|
|
648
|
+
for (const r of _permRsV2.values())
|
|
649
|
+
if (
|
|
650
|
+
r.status === PERM_RULE_MATURITY_V2.ACTIVE &&
|
|
651
|
+
t - r.lastTouchedAt >= _permIdleMs
|
|
652
|
+
) {
|
|
653
|
+
r.status = PERM_RULE_MATURITY_V2.DISABLED;
|
|
654
|
+
r.updatedAt = t;
|
|
655
|
+
flipped.push(r.id);
|
|
656
|
+
}
|
|
657
|
+
return { flipped, count: flipped.length };
|
|
658
|
+
}
|
|
659
|
+
export function autoDenyStuckPermChecksV2({ now } = {}) {
|
|
660
|
+
const t = now ?? Date.now();
|
|
661
|
+
const flipped = [];
|
|
662
|
+
for (const c of _permCsV2.values())
|
|
663
|
+
if (
|
|
664
|
+
c.status === PERM_CHECK_LIFECYCLE_V2.EVALUATING &&
|
|
665
|
+
c.startedAt != null &&
|
|
666
|
+
t - c.startedAt >= _permStuckMs
|
|
667
|
+
) {
|
|
668
|
+
c.status = PERM_CHECK_LIFECYCLE_V2.DENIED;
|
|
669
|
+
c.updatedAt = t;
|
|
670
|
+
if (!c.settledAt) c.settledAt = t;
|
|
671
|
+
c.metadata.denyReason = "auto-deny-stuck";
|
|
672
|
+
flipped.push(c.id);
|
|
673
|
+
}
|
|
674
|
+
return { flipped, count: flipped.length };
|
|
675
|
+
}
|
|
676
|
+
export function getPermissionEngineGovStatsV2() {
|
|
677
|
+
const rulesByStatus = {};
|
|
678
|
+
for (const v of Object.values(PERM_RULE_MATURITY_V2)) rulesByStatus[v] = 0;
|
|
679
|
+
for (const r of _permRsV2.values()) rulesByStatus[r.status]++;
|
|
680
|
+
const checksByStatus = {};
|
|
681
|
+
for (const v of Object.values(PERM_CHECK_LIFECYCLE_V2)) checksByStatus[v] = 0;
|
|
682
|
+
for (const c of _permCsV2.values()) checksByStatus[c.status]++;
|
|
683
|
+
return {
|
|
684
|
+
totalPermRulesV2: _permRsV2.size,
|
|
685
|
+
totalPermChecksV2: _permCsV2.size,
|
|
686
|
+
maxActivePermRulesPerOwner: _permMaxActivePerOwner,
|
|
687
|
+
maxPendingPermChecksPerRule: _permMaxPendingChecksPerRule,
|
|
688
|
+
permRuleIdleMs: _permIdleMs,
|
|
689
|
+
permCheckStuckMs: _permStuckMs,
|
|
690
|
+
rulesByStatus,
|
|
691
|
+
checksByStatus,
|
|
692
|
+
};
|
|
693
|
+
}
|