chainlesschain 0.143.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/a2a.js +196 -28
- package/src/commands/activitypub.js +364 -27
- package/src/commands/agent-network.js +217 -0
- package/src/commands/agent.js +587 -103
- package/src/commands/audit.js +206 -0
- package/src/commands/automation.js +201 -0
- package/src/commands/bi.js +355 -27
- package/src/commands/bm25.js +111 -27
- package/src/commands/browse.js +403 -29
- package/src/commands/ccron.js +128 -28
- package/src/commands/chat.js +207 -0
- package/src/commands/codegen.js +207 -0
- package/src/commands/collab.js +211 -0
- package/src/commands/compliance.js +824 -34
- package/src/commands/compt.js +127 -29
- package/src/commands/consol.js +8 -2
- package/src/commands/cowork.js +783 -34
- package/src/commands/crosschain.js +182 -28
- package/src/commands/dao.js +182 -28
- 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 +385 -27
- package/src/commands/economy.js +205 -50
- package/src/commands/evolution.js +203 -50
- package/src/commands/evomap.js +387 -27
- package/src/commands/export.js +213 -0
- package/src/commands/federation.js +209 -0
- package/src/commands/fflag.js +74 -22
- package/src/commands/fusion.js +205 -0
- package/src/commands/git.js +177 -37
- package/src/commands/governance.js +209 -0
- package/src/commands/hardening.js +209 -0
- package/src/commands/hmemory.js +204 -50
- package/src/commands/hook.js +209 -0
- package/src/commands/import.js +209 -0
- package/src/commands/incentive.js +209 -0
- package/src/commands/inference.js +170 -34
- package/src/commands/infra.js +203 -0
- package/src/commands/instinct.js +209 -0
- package/src/commands/ipfs.js +207 -0
- package/src/commands/itbudget.js +149 -33
- package/src/commands/kg.js +206 -0
- package/src/commands/llm.js +217 -0
- package/src/commands/lowcode.js +195 -38
- package/src/commands/marketplace.js +206 -0
- package/src/commands/matrix.js +386 -27
- package/src/commands/mcp.js +217 -0
- package/src/commands/mcpscaf.js +145 -33
- package/src/commands/meminj.js +145 -33
- 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 +387 -27
- package/src/commands/note.js +205 -0
- package/src/commands/ops.js +219 -0
- package/src/commands/orchestrate.js +217 -0
- package/src/commands/orchgov.js +144 -33
- package/src/commands/org.js +209 -0
- package/src/commands/p2p.js +209 -0
- package/src/commands/pdfp.js +109 -27
- package/src/commands/perception.js +209 -0
- package/src/commands/perf.js +169 -32
- package/src/commands/perm.js +144 -33
- package/src/commands/permmem.js +203 -0
- package/src/commands/pipeline.js +207 -52
- package/src/commands/planmode.js +141 -32
- package/src/commands/plugin-ecosystem.js +209 -0
- package/src/commands/pqc.js +213 -0
- package/src/commands/privacy.js +203 -0
- package/src/commands/promcomp.js +111 -27
- package/src/commands/quantization.js +207 -0
- package/src/commands/rcache.js +205 -0
- package/src/commands/recommend.js +410 -34
- package/src/commands/reputation.js +208 -0
- package/src/commands/runtime.js +205 -0
- package/src/commands/sandbox.js +206 -0
- package/src/commands/scim.js +209 -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/session.js +209 -0
- package/src/commands/sganal.js +123 -29
- package/src/commands/siem.js +201 -34
- package/src/commands/skill.js +207 -0
- package/src/commands/sla.js +212 -0
- package/src/commands/slotfill.js +146 -33
- package/src/commands/social.js +358 -32
- package/src/commands/sso.js +209 -0
- package/src/commands/stress.js +206 -0
- package/src/commands/svccont.js +145 -33
- package/src/commands/sync.js +209 -0
- package/src/commands/tech.js +209 -0
- package/src/commands/tenant.js +217 -0
- package/src/commands/terraform.js +206 -0
- package/src/commands/tms.js +171 -33
- package/src/commands/tokens.js +209 -0
- package/src/commands/topiccls.js +146 -33
- package/src/commands/trust.js +217 -0
- package/src/commands/uprof.js +141 -32
- package/src/commands/vcheck.js +122 -28
- package/src/commands/wallet.js +209 -0
- package/src/commands/webfetch.js +141 -32
- package/src/commands/workflow.js +203 -0
- package/src/commands/zkp.js +184 -28
- package/src/index.js +180 -0
- package/src/lib/a2a-protocol.js +319 -51
- package/src/lib/activitypub-bridge.js +622 -50
- package/src/lib/agent-economy.js +304 -51
- package/src/lib/agent-network.js +341 -0
- package/src/lib/aiops.js +346 -0
- package/src/lib/app-builder.js +279 -46
- package/src/lib/audit-logger.js +321 -0
- package/src/lib/automation-engine.js +335 -0
- package/src/lib/autonomous-agent.js +284 -48
- package/src/lib/autonomous-developer.js +332 -0
- package/src/lib/bi-engine.js +616 -49
- package/src/lib/bm25-search.js +301 -49
- package/src/lib/browser-automation.js +630 -49
- package/src/lib/chat-core.js +336 -0
- package/src/lib/claude-code-bridge.js +341 -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/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-recommendation.js +351 -0
- 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-share.js +338 -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/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 +626 -49
- package/src/lib/evolution-system.js +278 -47
- package/src/lib/evomap-governance.js +334 -0
- 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/federation-hardening.js +340 -0
- 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/hook-manager.js +341 -0
- package/src/lib/inference-network.js +308 -51
- package/src/lib/instinct-manager.js +346 -0
- package/src/lib/ipfs-storage.js +334 -0
- package/src/lib/iteration-budget.js +302 -50
- package/src/lib/knowledge-exporter.js +341 -0
- package/src/lib/knowledge-graph.js +333 -0
- package/src/lib/knowledge-importer.js +341 -0
- package/src/lib/llm-providers.js +346 -0
- package/src/lib/matrix-bridge.js +620 -47
- package/src/lib/mcp-registry.js +346 -0
- package/src/lib/mcp-scaffold.js +318 -54
- package/src/lib/memory-injection.js +288 -49
- 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 +622 -49
- package/src/lib/note-versioning.js +339 -0
- package/src/lib/orchestrator.js +293 -48
- package/src/lib/org-manager.js +336 -0
- package/src/lib/p2p-manager.js +341 -0
- package/src/lib/pdf-parser.js +298 -49
- package/src/lib/perception.js +346 -0
- package/src/lib/perf-tuning.js +309 -50
- package/src/lib/permanent-memory.js +327 -0
- 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/plugin-ecosystem.js +346 -0
- package/src/lib/pqc-manager.js +346 -0
- package/src/lib/privacy-computing.js +335 -0
- package/src/lib/protocol-fusion.js +338 -0
- package/src/lib/quantization.js +337 -0
- package/src/lib/reputation-optimizer.js +340 -0
- package/src/lib/response-cache.js +333 -0
- package/src/lib/sandbox-v2.js +327 -0
- package/src/lib/scim-manager.js +346 -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-manager.js +334 -0
- 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-loader.js +334 -0
- 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/social-manager.js +330 -0
- package/src/lib/sso-manager.js +340 -0
- package/src/lib/stress-tester.js +342 -0
- package/src/lib/sub-agent-registry.js +302 -53
- package/src/lib/sync-manager.js +336 -0
- package/src/lib/task-model-selector.js +302 -50
- package/src/lib/tech-learning-engine.js +341 -0
- package/src/lib/tenant-saas.js +341 -0
- package/src/lib/terraform-manager.js +333 -0
- package/src/lib/threat-intel.js +330 -0
- package/src/lib/todo-manager.js +281 -47
- package/src/lib/token-incentive.js +341 -0
- package/src/lib/token-tracker.js +336 -0
- package/src/lib/topic-classifier.js +297 -49
- 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/user-profile.js +294 -50
- package/src/lib/version-checker.js +304 -50
- package/src/lib/wallet-manager.js +336 -0
- package/src/lib/web-fetch.js +292 -51
- package/src/lib/workflow-engine.js +330 -0
- package/src/lib/zkp-engine.js +286 -49
package/src/lib/perf-tuning.js
CHANGED
|
@@ -736,25 +736,62 @@ export function _resetState() {
|
|
|
736
736
|
/* CLI is stateless; helper exists for parity with other libs */
|
|
737
737
|
}
|
|
738
738
|
|
|
739
|
-
|
|
740
739
|
// ===== V2 Surface: Perf Tuning governance overlay (CLI v0.140.0) =====
|
|
741
740
|
export const PERF_TUNING_PROFILE_MATURITY_V2 = Object.freeze({
|
|
742
|
-
PENDING: "pending",
|
|
741
|
+
PENDING: "pending",
|
|
742
|
+
ACTIVE: "active",
|
|
743
|
+
STALE: "stale",
|
|
744
|
+
DECOMMISSIONED: "decommissioned",
|
|
743
745
|
});
|
|
744
746
|
export const PERF_BENCH_LIFECYCLE_V2 = Object.freeze({
|
|
745
|
-
QUEUED: "queued",
|
|
747
|
+
QUEUED: "queued",
|
|
748
|
+
RUNNING: "running",
|
|
749
|
+
COMPLETED: "completed",
|
|
750
|
+
FAILED: "failed",
|
|
751
|
+
CANCELLED: "cancelled",
|
|
746
752
|
});
|
|
747
753
|
|
|
748
754
|
const _ptpTrans = new Map([
|
|
749
|
-
[
|
|
750
|
-
|
|
751
|
-
|
|
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
|
+
],
|
|
752
776
|
[PERF_TUNING_PROFILE_MATURITY_V2.DECOMMISSIONED, new Set()],
|
|
753
777
|
]);
|
|
754
778
|
const _ptpTerminal = new Set([PERF_TUNING_PROFILE_MATURITY_V2.DECOMMISSIONED]);
|
|
755
779
|
const _pbTrans = new Map([
|
|
756
|
-
[
|
|
757
|
-
|
|
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
|
+
],
|
|
758
795
|
[PERF_BENCH_LIFECYCLE_V2.COMPLETED, new Set()],
|
|
759
796
|
[PERF_BENCH_LIFECYCLE_V2.FAILED, new Set()],
|
|
760
797
|
[PERF_BENCH_LIFECYCLE_V2.CANCELLED, new Set()],
|
|
@@ -767,76 +804,298 @@ let _ptpMaxPendingBenchesPerProfile = 10;
|
|
|
767
804
|
let _ptpIdleMs = 7 * 24 * 60 * 60 * 1000;
|
|
768
805
|
let _pbStuckMs = 30 * 60 * 1000;
|
|
769
806
|
|
|
770
|
-
function _ptpPos(n, lbl) {
|
|
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
|
+
}
|
|
771
813
|
|
|
772
|
-
export function setMaxActivePerfTuningProfilesPerOwnerV2(n) {
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
export function
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
export function
|
|
779
|
-
|
|
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
|
+
}
|
|
780
841
|
|
|
781
842
|
export function _resetStatePerfTuningV2() {
|
|
782
|
-
_ptpsV2.clear();
|
|
783
|
-
|
|
784
|
-
|
|
843
|
+
_ptpsV2.clear();
|
|
844
|
+
_pbsV2.clear();
|
|
845
|
+
_ptpMaxActivePerOwner = 6;
|
|
846
|
+
_ptpMaxPendingBenchesPerProfile = 10;
|
|
847
|
+
_ptpIdleMs = 7 * 24 * 60 * 60 * 1000;
|
|
848
|
+
_pbStuckMs = 30 * 60 * 1000;
|
|
785
849
|
}
|
|
786
850
|
|
|
787
|
-
export function registerPerfTuningProfileV2({
|
|
851
|
+
export function registerPerfTuningProfileV2({
|
|
852
|
+
id,
|
|
853
|
+
owner,
|
|
854
|
+
target,
|
|
855
|
+
metadata,
|
|
856
|
+
} = {}) {
|
|
788
857
|
if (!id || typeof id !== "string") throw new Error("id is required");
|
|
789
858
|
if (!owner || typeof owner !== "string") throw new Error("owner is required");
|
|
790
|
-
if (_ptpsV2.has(id))
|
|
859
|
+
if (_ptpsV2.has(id))
|
|
860
|
+
throw new Error(`perf tuning profile ${id} already registered`);
|
|
791
861
|
const now = Date.now();
|
|
792
|
-
const p = {
|
|
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
|
+
};
|
|
793
874
|
_ptpsV2.set(id, p);
|
|
794
875
|
return { ...p, metadata: { ...p.metadata } };
|
|
795
876
|
}
|
|
796
|
-
function _ptpCheckP(from, to) {
|
|
797
|
-
|
|
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
|
+
}
|
|
798
892
|
|
|
799
893
|
export function activatePerfTuningProfileV2(id) {
|
|
800
|
-
const p = _ptpsV2.get(id);
|
|
894
|
+
const p = _ptpsV2.get(id);
|
|
895
|
+
if (!p) throw new Error(`perf tuning profile ${id} not found`);
|
|
801
896
|
_ptpCheckP(p.status, PERF_TUNING_PROFILE_MATURITY_V2.ACTIVE);
|
|
802
897
|
const recovery = p.status === PERF_TUNING_PROFILE_MATURITY_V2.STALE;
|
|
803
|
-
if (!recovery) {
|
|
804
|
-
|
|
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;
|
|
805
943
|
return { ...p, metadata: { ...p.metadata } };
|
|
806
944
|
}
|
|
807
|
-
export function
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
945
|
+
export function listPerfTuningProfilesV2() {
|
|
946
|
+
return [..._ptpsV2.values()].map((p) => ({
|
|
947
|
+
...p,
|
|
948
|
+
metadata: { ...p.metadata },
|
|
949
|
+
}));
|
|
950
|
+
}
|
|
812
951
|
|
|
813
|
-
function _pbCountPending(profileId) {
|
|
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
|
+
}
|
|
814
963
|
|
|
815
964
|
export function createPerfBenchV2({ id, profileId, scenario, metadata } = {}) {
|
|
816
965
|
if (!id || typeof id !== "string") throw new Error("id is required");
|
|
817
|
-
if (!profileId || typeof profileId !== "string")
|
|
966
|
+
if (!profileId || typeof profileId !== "string")
|
|
967
|
+
throw new Error("profileId is required");
|
|
818
968
|
if (_pbsV2.has(id)) throw new Error(`perf bench ${id} already exists`);
|
|
819
|
-
if (!_ptpsV2.has(profileId))
|
|
969
|
+
if (!_ptpsV2.has(profileId))
|
|
970
|
+
throw new Error(`perf tuning profile ${profileId} not found`);
|
|
820
971
|
const pending = _pbCountPending(profileId);
|
|
821
|
-
if (pending >= _ptpMaxPendingBenchesPerProfile)
|
|
972
|
+
if (pending >= _ptpMaxPendingBenchesPerProfile)
|
|
973
|
+
throw new Error(
|
|
974
|
+
`max pending perf benches per profile (${_ptpMaxPendingBenchesPerProfile}) reached for ${profileId}`,
|
|
975
|
+
);
|
|
822
976
|
const now = Date.now();
|
|
823
|
-
const b = {
|
|
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
|
+
};
|
|
824
988
|
_pbsV2.set(id, b);
|
|
825
989
|
return { ...b, metadata: { ...b.metadata } };
|
|
826
990
|
}
|
|
827
|
-
function _pbCheckB(from, to) {
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
export function
|
|
833
|
-
|
|
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
|
+
}
|
|
834
1049
|
|
|
835
|
-
export function autoStaleIdlePerfTuningProfilesV2({ now } = {}) {
|
|
836
|
-
|
|
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
|
+
}
|
|
837
1081
|
|
|
838
1082
|
export function getPerfTuningGovStatsV2() {
|
|
839
|
-
const profilesByStatus = {};
|
|
840
|
-
|
|
841
|
-
|
|
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
|
+
};
|
|
842
1101
|
}
|