chainlesschain 0.51.0 → 0.81.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/assets/web-panel/.build-hash +1 -1
- package/src/assets/web-panel/assets/{AppLayout-Rvi759IS.js → AppLayout-6SPt_8Y_.js} +1 -1
- package/src/assets/web-panel/assets/{Dashboard-DBhFxXYQ.js → Dashboard-Br7kCwKJ.js} +2 -2
- package/src/assets/web-panel/assets/Dashboard-CKeMmCoT.css +1 -0
- package/src/assets/web-panel/assets/{index-uL0cZ8N_.js → index-tN-8TosE.js} +2 -2
- package/src/assets/web-panel/index.html +2 -2
- package/src/commands/a2a.js +380 -0
- package/src/commands/agent-network.js +785 -0
- package/src/commands/automation.js +654 -0
- package/src/commands/bi.js +348 -0
- package/src/commands/crosschain.js +218 -0
- package/src/commands/dao.js +565 -0
- package/src/commands/did-v2.js +620 -0
- package/src/commands/dlp.js +341 -0
- package/src/commands/economy.js +578 -0
- package/src/commands/evolution.js +391 -0
- package/src/commands/evomap.js +394 -0
- package/src/commands/federation.js +283 -0
- package/src/commands/hmemory.js +442 -0
- package/src/commands/inference.js +318 -0
- package/src/commands/lowcode.js +356 -0
- package/src/commands/marketplace.js +256 -0
- package/src/commands/perf.js +433 -0
- package/src/commands/pipeline.js +449 -0
- package/src/commands/plugin-ecosystem.js +517 -0
- package/src/commands/privacy.js +321 -0
- package/src/commands/reputation.js +261 -0
- package/src/commands/sandbox.js +401 -0
- package/src/commands/siem.js +246 -0
- package/src/commands/sla.js +259 -0
- package/src/commands/social.js +311 -0
- package/src/commands/sso.js +798 -0
- package/src/commands/stress.js +230 -0
- package/src/commands/terraform.js +245 -0
- package/src/commands/workflow.js +320 -0
- package/src/commands/zkp.js +562 -1
- package/src/index.js +21 -0
- package/src/lib/a2a-protocol.js +451 -0
- package/src/lib/agent-economy.js +479 -0
- package/src/lib/agent-network.js +1121 -0
- package/src/lib/app-builder.js +239 -0
- package/src/lib/automation-engine.js +948 -0
- package/src/lib/bi-engine.js +338 -0
- package/src/lib/cross-chain.js +345 -0
- package/src/lib/dao-governance.js +569 -0
- package/src/lib/did-v2-manager.js +1127 -0
- package/src/lib/dlp-engine.js +389 -0
- package/src/lib/evolution-system.js +453 -0
- package/src/lib/evomap-federation.js +177 -0
- package/src/lib/evomap-governance.js +276 -0
- package/src/lib/federation-hardening.js +259 -0
- package/src/lib/hierarchical-memory.js +481 -0
- package/src/lib/inference-network.js +330 -0
- package/src/lib/perf-tuning.js +734 -0
- package/src/lib/pipeline-orchestrator.js +928 -0
- package/src/lib/plugin-ecosystem.js +1109 -0
- package/src/lib/privacy-computing.js +427 -0
- package/src/lib/reputation-optimizer.js +299 -0
- package/src/lib/sandbox-v2.js +306 -0
- package/src/lib/siem-exporter.js +333 -0
- package/src/lib/skill-marketplace.js +325 -0
- package/src/lib/sla-manager.js +275 -0
- package/src/lib/social-graph-analytics.js +707 -0
- package/src/lib/sso-manager.js +841 -0
- package/src/lib/stress-tester.js +330 -0
- package/src/lib/terraform-manager.js +363 -0
- package/src/lib/workflow-engine.js +454 -1
- package/src/lib/zkp-engine.js +523 -20
- package/src/assets/web-panel/assets/Dashboard-BS-tzGNj.css +0 -1
package/src/commands/privacy.js
CHANGED
|
@@ -23,6 +23,32 @@ import {
|
|
|
23
23
|
dpPublish,
|
|
24
24
|
heQuery,
|
|
25
25
|
getPrivacyReport,
|
|
26
|
+
// V2 surface
|
|
27
|
+
FL_STATUS_V2,
|
|
28
|
+
MPC_STATUS_V2,
|
|
29
|
+
DP_MECHANISM_V2,
|
|
30
|
+
HE_SCHEME_V2,
|
|
31
|
+
MPC_PROTOCOL_V2,
|
|
32
|
+
PRIVACY_DEFAULT_MAX_ACTIVE_MPC_COMPUTATIONS,
|
|
33
|
+
setMaxActiveMpcComputations,
|
|
34
|
+
getMaxActiveMpcComputations,
|
|
35
|
+
getActiveMpcCount,
|
|
36
|
+
setPrivacyBudgetLimit,
|
|
37
|
+
getPrivacyBudgetLimit,
|
|
38
|
+
getPrivacyBudgetSpent,
|
|
39
|
+
resetPrivacyBudget,
|
|
40
|
+
createModelV2,
|
|
41
|
+
trainRoundV2,
|
|
42
|
+
aggregateRound,
|
|
43
|
+
failModelV2,
|
|
44
|
+
setFLStatusV2,
|
|
45
|
+
createComputationV2,
|
|
46
|
+
submitShareV2,
|
|
47
|
+
failComputation,
|
|
48
|
+
setMPCStatusV2,
|
|
49
|
+
dpPublishV2,
|
|
50
|
+
heQueryV2,
|
|
51
|
+
getPrivacyStatsV2,
|
|
26
52
|
} from "../lib/privacy-computing.js";
|
|
27
53
|
|
|
28
54
|
function _dbFromCtx(cmd) {
|
|
@@ -341,5 +367,300 @@ export function registerPrivacyCommand(program) {
|
|
|
341
367
|
);
|
|
342
368
|
});
|
|
343
369
|
|
|
370
|
+
/* ──────────────────────────────────────────────────────────
|
|
371
|
+
* V2 — Phase 91
|
|
372
|
+
* ────────────────────────────────────────────────────────── */
|
|
373
|
+
|
|
374
|
+
pc.command("fl-statuses-v2")
|
|
375
|
+
.description("List V2 FL statuses")
|
|
376
|
+
.option("--json", "JSON output")
|
|
377
|
+
.action((opts) => {
|
|
378
|
+
const v = Object.values(FL_STATUS_V2);
|
|
379
|
+
if (opts.json) return console.log(JSON.stringify(v, null, 2));
|
|
380
|
+
v.forEach((s) => console.log(s));
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
pc.command("mpc-statuses-v2")
|
|
384
|
+
.description("List V2 MPC statuses")
|
|
385
|
+
.option("--json", "JSON output")
|
|
386
|
+
.action((opts) => {
|
|
387
|
+
const v = Object.values(MPC_STATUS_V2);
|
|
388
|
+
if (opts.json) return console.log(JSON.stringify(v, null, 2));
|
|
389
|
+
v.forEach((s) => console.log(s));
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
pc.command("dp-mechanisms-v2")
|
|
393
|
+
.description("List V2 DP mechanisms")
|
|
394
|
+
.option("--json", "JSON output")
|
|
395
|
+
.action((opts) => {
|
|
396
|
+
const v = Object.values(DP_MECHANISM_V2);
|
|
397
|
+
if (opts.json) return console.log(JSON.stringify(v, null, 2));
|
|
398
|
+
v.forEach((s) => console.log(s));
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
pc.command("he-schemes-v2")
|
|
402
|
+
.description("List V2 HE schemes")
|
|
403
|
+
.option("--json", "JSON output")
|
|
404
|
+
.action((opts) => {
|
|
405
|
+
const v = Object.values(HE_SCHEME_V2);
|
|
406
|
+
if (opts.json) return console.log(JSON.stringify(v, null, 2));
|
|
407
|
+
v.forEach((s) => console.log(s));
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
pc.command("mpc-protocols-v2")
|
|
411
|
+
.description("List V2 MPC protocols")
|
|
412
|
+
.option("--json", "JSON output")
|
|
413
|
+
.action((opts) => {
|
|
414
|
+
const v = Object.values(MPC_PROTOCOL_V2);
|
|
415
|
+
if (opts.json) return console.log(JSON.stringify(v, null, 2));
|
|
416
|
+
v.forEach((s) => console.log(s));
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
pc.command("default-max-active-mpc")
|
|
420
|
+
.description("Show V2 default max active MPC computations")
|
|
421
|
+
.action(() =>
|
|
422
|
+
console.log(String(PRIVACY_DEFAULT_MAX_ACTIVE_MPC_COMPUTATIONS)),
|
|
423
|
+
);
|
|
424
|
+
|
|
425
|
+
pc.command("max-active-mpc")
|
|
426
|
+
.description("Show current max active MPC computations")
|
|
427
|
+
.action(() => console.log(String(getMaxActiveMpcComputations())));
|
|
428
|
+
|
|
429
|
+
pc.command("active-mpc-count")
|
|
430
|
+
.description("Show currently-active MPC computation count")
|
|
431
|
+
.action(() => console.log(String(getActiveMpcCount())));
|
|
432
|
+
|
|
433
|
+
pc.command("set-max-active-mpc <n>")
|
|
434
|
+
.description("Set max concurrent active MPC computations")
|
|
435
|
+
.action((n) => {
|
|
436
|
+
setMaxActiveMpcComputations(Number(n));
|
|
437
|
+
console.log(`max-active-mpc = ${getMaxActiveMpcComputations()}`);
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
pc.command("budget-limit")
|
|
441
|
+
.description("Show privacy budget limit")
|
|
442
|
+
.action(() => console.log(String(getPrivacyBudgetLimit())));
|
|
443
|
+
|
|
444
|
+
pc.command("budget-spent")
|
|
445
|
+
.description("Show privacy budget spent")
|
|
446
|
+
.action(() => console.log(String(getPrivacyBudgetSpent())));
|
|
447
|
+
|
|
448
|
+
pc.command("set-budget-limit <n>")
|
|
449
|
+
.description("Set privacy budget limit")
|
|
450
|
+
.action((n) => {
|
|
451
|
+
setPrivacyBudgetLimit(Number(n));
|
|
452
|
+
console.log(`budget-limit = ${getPrivacyBudgetLimit()}`);
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
pc.command("reset-budget")
|
|
456
|
+
.description("Reset privacy budget spent counter to 0")
|
|
457
|
+
.action(() => {
|
|
458
|
+
resetPrivacyBudget();
|
|
459
|
+
console.log("budget reset");
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
pc.command("create-model-v2 <name>")
|
|
463
|
+
.description("V2 create FL model (throws on invalid input)")
|
|
464
|
+
.option("-t, --total-rounds <n>", "Total rounds (default 10)")
|
|
465
|
+
.option("-l, --learning-rate <n>", "Learning rate (default 0.01)")
|
|
466
|
+
.option("-a, --architecture <arch>", "Architecture")
|
|
467
|
+
.option("-m, --model-type <type>", "Model type")
|
|
468
|
+
.option("--json", "JSON output")
|
|
469
|
+
.action((name, opts) => {
|
|
470
|
+
const db = _dbFromCtx(pc);
|
|
471
|
+
const m = createModelV2(db, {
|
|
472
|
+
name,
|
|
473
|
+
totalRounds: opts.totalRounds ? Number(opts.totalRounds) : undefined,
|
|
474
|
+
learningRate: opts.learningRate ? Number(opts.learningRate) : undefined,
|
|
475
|
+
architecture: opts.architecture,
|
|
476
|
+
modelType: opts.modelType,
|
|
477
|
+
});
|
|
478
|
+
if (opts.json) return console.log(JSON.stringify(m, null, 2));
|
|
479
|
+
console.log(`Model: ${m.id} (${m.name}, rounds=${m.total_rounds})`);
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
pc.command("train-round-v2 <model-id>")
|
|
483
|
+
.description("V2 train one FL round (auto initializing → training)")
|
|
484
|
+
.option("--json", "JSON output")
|
|
485
|
+
.action((id, opts) => {
|
|
486
|
+
const db = _dbFromCtx(pc);
|
|
487
|
+
const m = trainRoundV2(db, id);
|
|
488
|
+
if (opts.json) return console.log(JSON.stringify(m, null, 2));
|
|
489
|
+
console.log(
|
|
490
|
+
`Round ${m.current_round}/${m.total_rounds} status=${m.status} acc=${m.accuracy}`,
|
|
491
|
+
);
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
pc.command("aggregate-round <model-id>")
|
|
495
|
+
.description("Aggregate FL round (training → training next / completed)")
|
|
496
|
+
.option("--json", "JSON output")
|
|
497
|
+
.action((id, opts) => {
|
|
498
|
+
const db = _dbFromCtx(pc);
|
|
499
|
+
const m = aggregateRound(db, id);
|
|
500
|
+
if (opts.json) return console.log(JSON.stringify(m, null, 2));
|
|
501
|
+
console.log(`Model ${m.id} status=${m.status} round=${m.current_round}`);
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
pc.command("fail-model-v2 <model-id>")
|
|
505
|
+
.description("V2 fail FL model (any non-terminal → failed)")
|
|
506
|
+
.option("-e, --error <msg>", "Error message")
|
|
507
|
+
.option("--json", "JSON output")
|
|
508
|
+
.action((id, opts) => {
|
|
509
|
+
const db = _dbFromCtx(pc);
|
|
510
|
+
const m = failModelV2(db, id, { error: opts.error });
|
|
511
|
+
if (opts.json) return console.log(JSON.stringify(m, null, 2));
|
|
512
|
+
console.log(`Model ${m.id} failed: ${m.error_message || ""}`);
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
pc.command("set-fl-status <model-id> <status>")
|
|
516
|
+
.description("V2 state-machine guarded FL status setter")
|
|
517
|
+
.option("-a, --accuracy <n>")
|
|
518
|
+
.option("-l, --loss <n>")
|
|
519
|
+
.option("-e, --error <msg>")
|
|
520
|
+
.option("--json", "JSON output")
|
|
521
|
+
.action((id, status, opts) => {
|
|
522
|
+
const db = _dbFromCtx(pc);
|
|
523
|
+
const patch = {};
|
|
524
|
+
if (opts.accuracy !== undefined) patch.accuracy = Number(opts.accuracy);
|
|
525
|
+
if (opts.loss !== undefined) patch.loss = Number(opts.loss);
|
|
526
|
+
if (opts.error !== undefined) patch.errorMessage = opts.error;
|
|
527
|
+
const m = setFLStatusV2(db, id, status, patch);
|
|
528
|
+
if (opts.json) return console.log(JSON.stringify(m, null, 2));
|
|
529
|
+
console.log(`Model ${m.id} status=${m.status}`);
|
|
530
|
+
});
|
|
531
|
+
|
|
532
|
+
pc.command("create-computation-v2 <type>")
|
|
533
|
+
.description("V2 create MPC computation (throws on invalid input)")
|
|
534
|
+
.option("-p, --protocol <proto>", "Protocol (shamir|beaver|gmw)")
|
|
535
|
+
.option("-i, --participants <csv>", "Comma-separated participant IDs")
|
|
536
|
+
.option("-s, --shares-required <n>", "Shares required")
|
|
537
|
+
.option("--json", "JSON output")
|
|
538
|
+
.action((type, opts) => {
|
|
539
|
+
const db = _dbFromCtx(pc);
|
|
540
|
+
const ids = opts.participants
|
|
541
|
+
? opts.participants
|
|
542
|
+
.split(",")
|
|
543
|
+
.map((s) => s.trim())
|
|
544
|
+
.filter(Boolean)
|
|
545
|
+
: [];
|
|
546
|
+
const c = createComputationV2(db, {
|
|
547
|
+
computationType: type,
|
|
548
|
+
protocol: opts.protocol,
|
|
549
|
+
participantIds: ids,
|
|
550
|
+
sharesRequired: opts.sharesRequired
|
|
551
|
+
? Number(opts.sharesRequired)
|
|
552
|
+
: undefined,
|
|
553
|
+
});
|
|
554
|
+
if (opts.json) return console.log(JSON.stringify(c, null, 2));
|
|
555
|
+
console.log(
|
|
556
|
+
`Computation: ${c.id} protocol=${c.protocol} required=${c.shares_required}`,
|
|
557
|
+
);
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
pc.command("submit-share-v2 <comp-id>")
|
|
561
|
+
.description("V2 submit MPC share (state-guarded)")
|
|
562
|
+
.option("--json", "JSON output")
|
|
563
|
+
.action((id, opts) => {
|
|
564
|
+
const db = _dbFromCtx(pc);
|
|
565
|
+
const c = submitShareV2(db, id);
|
|
566
|
+
if (opts.json) return console.log(JSON.stringify(c, null, 2));
|
|
567
|
+
console.log(
|
|
568
|
+
`Comp ${c.id} shares=${c.shares_received}/${c.shares_required} status=${c.status}`,
|
|
569
|
+
);
|
|
570
|
+
});
|
|
571
|
+
|
|
572
|
+
pc.command("fail-computation <comp-id>")
|
|
573
|
+
.description("Fail MPC computation (any non-terminal → failed)")
|
|
574
|
+
.option("-e, --error <msg>")
|
|
575
|
+
.option("--json", "JSON output")
|
|
576
|
+
.action((id, opts) => {
|
|
577
|
+
const db = _dbFromCtx(pc);
|
|
578
|
+
const c = failComputation(db, id, { error: opts.error });
|
|
579
|
+
if (opts.json) return console.log(JSON.stringify(c, null, 2));
|
|
580
|
+
console.log(`Comp ${c.id} failed: ${c.error_message || ""}`);
|
|
581
|
+
});
|
|
582
|
+
|
|
583
|
+
pc.command("set-mpc-status <comp-id> <status>")
|
|
584
|
+
.description("V2 state-machine guarded MPC status setter")
|
|
585
|
+
.option("-h, --result-hash <hash>")
|
|
586
|
+
.option("-e, --error <msg>")
|
|
587
|
+
.option("--json", "JSON output")
|
|
588
|
+
.action((id, status, opts) => {
|
|
589
|
+
const db = _dbFromCtx(pc);
|
|
590
|
+
const patch = {};
|
|
591
|
+
if (opts.resultHash !== undefined) patch.resultHash = opts.resultHash;
|
|
592
|
+
if (opts.error !== undefined) patch.errorMessage = opts.error;
|
|
593
|
+
const c = setMPCStatusV2(db, id, status, patch);
|
|
594
|
+
if (opts.json) return console.log(JSON.stringify(c, null, 2));
|
|
595
|
+
console.log(`Comp ${c.id} status=${c.status}`);
|
|
596
|
+
});
|
|
597
|
+
|
|
598
|
+
pc.command("dp-publish-v2")
|
|
599
|
+
.description("V2 DP publish (throws on invalid input / exceeded budget)")
|
|
600
|
+
.requiredOption("-d, --data <n>", "Data value", Number)
|
|
601
|
+
.option("-e, --epsilon <n>", "Epsilon", Number)
|
|
602
|
+
.option("--delta <n>", "Delta", Number)
|
|
603
|
+
.option("-m, --mechanism <mech>", "Mechanism")
|
|
604
|
+
.option("-s, --sensitivity <n>", "Sensitivity", Number)
|
|
605
|
+
.option("--json", "JSON output")
|
|
606
|
+
.action((opts) => {
|
|
607
|
+
const db = _dbFromCtx(pc);
|
|
608
|
+
const r = dpPublishV2(db, {
|
|
609
|
+
data: opts.data,
|
|
610
|
+
epsilon: opts.epsilon,
|
|
611
|
+
delta: opts.delta,
|
|
612
|
+
mechanism: opts.mechanism,
|
|
613
|
+
sensitivity: opts.sensitivity,
|
|
614
|
+
});
|
|
615
|
+
if (opts.json) return console.log(JSON.stringify(r, null, 2));
|
|
616
|
+
console.log(
|
|
617
|
+
`Published: orig=${r.originalValue} noised=${r.noisedValue} ε=${r.epsilon}`,
|
|
618
|
+
);
|
|
619
|
+
});
|
|
620
|
+
|
|
621
|
+
pc.command("he-query-v2")
|
|
622
|
+
.description("V2 HE query (throws on invalid input)")
|
|
623
|
+
.requiredOption("-o, --operation <op>", "sum|product|mean|count")
|
|
624
|
+
.requiredOption("-d, --data <json>", "JSON array of numbers")
|
|
625
|
+
.option("-s, --scheme <scheme>", "Scheme")
|
|
626
|
+
.option("--json", "JSON output")
|
|
627
|
+
.action((opts) => {
|
|
628
|
+
let data;
|
|
629
|
+
try {
|
|
630
|
+
data = JSON.parse(opts.data);
|
|
631
|
+
} catch (_e) {
|
|
632
|
+
throw new Error("Invalid --data JSON");
|
|
633
|
+
}
|
|
634
|
+
const r = heQueryV2({
|
|
635
|
+
data,
|
|
636
|
+
operation: opts.operation,
|
|
637
|
+
scheme: opts.scheme,
|
|
638
|
+
});
|
|
639
|
+
if (opts.json) return console.log(JSON.stringify(r, null, 2));
|
|
640
|
+
console.log(
|
|
641
|
+
`Result: ${r.result} (${r.operation} over ${r.inputCount} items, scheme=${r.scheme})`,
|
|
642
|
+
);
|
|
643
|
+
});
|
|
644
|
+
|
|
645
|
+
pc.command("stats-v2")
|
|
646
|
+
.description("V2 all-enum-key zero-init stats")
|
|
647
|
+
.option("--json", "JSON output")
|
|
648
|
+
.action((opts) => {
|
|
649
|
+
const s = getPrivacyStatsV2();
|
|
650
|
+
if (opts.json) return console.log(JSON.stringify(s, null, 2));
|
|
651
|
+
console.log(
|
|
652
|
+
`Models: ${s.totalModels} Computations: ${s.totalComputations}`,
|
|
653
|
+
);
|
|
654
|
+
console.log(
|
|
655
|
+
`Active MPC: ${s.activeMpcCount}/${s.maxActiveMpcComputations}`,
|
|
656
|
+
);
|
|
657
|
+
console.log(
|
|
658
|
+
`Budget: ${s.budget.spent}/${s.budget.limit} (${s.budget.remaining} remaining)`,
|
|
659
|
+
);
|
|
660
|
+
console.log(
|
|
661
|
+
`Avg accuracy: ${s.avgAccuracy} Avg comp time ms: ${s.avgComputationTimeMs}`,
|
|
662
|
+
);
|
|
663
|
+
});
|
|
664
|
+
|
|
344
665
|
program.addCommand(pc);
|
|
345
666
|
}
|
|
@@ -18,6 +18,22 @@ import {
|
|
|
18
18
|
listOptimizationRuns,
|
|
19
19
|
applyOptimizedParams,
|
|
20
20
|
OPTIMIZATION_OBJECTIVES,
|
|
21
|
+
// V2 (Phase 60)
|
|
22
|
+
RUN_STATUS_V2,
|
|
23
|
+
OBJECTIVE_V2,
|
|
24
|
+
DECAY_MODEL_V2,
|
|
25
|
+
ANOMALY_METHOD_V2,
|
|
26
|
+
REPUTATION_DEFAULT_MAX_CONCURRENT,
|
|
27
|
+
setMaxConcurrentOptimizations,
|
|
28
|
+
getMaxConcurrentOptimizations,
|
|
29
|
+
getActiveOptimizationCount,
|
|
30
|
+
startOptimizationV2,
|
|
31
|
+
completeOptimization,
|
|
32
|
+
cancelOptimization,
|
|
33
|
+
failOptimization,
|
|
34
|
+
applyOptimization,
|
|
35
|
+
setRunStatus,
|
|
36
|
+
getReputationStatsV2,
|
|
21
37
|
} from "../lib/reputation-optimizer.js";
|
|
22
38
|
|
|
23
39
|
function _dbFromCtx(ctx) {
|
|
@@ -346,4 +362,249 @@ export function registerReputationCommand(program) {
|
|
|
346
362
|
for (const v of values) logger.log(` ${chalk.cyan(v)}`);
|
|
347
363
|
}
|
|
348
364
|
});
|
|
365
|
+
|
|
366
|
+
/* ── V2 (Phase 60) ───────────────────────────────────────── */
|
|
367
|
+
|
|
368
|
+
rep
|
|
369
|
+
.command("run-statuses")
|
|
370
|
+
.description(
|
|
371
|
+
"List V2 run statuses (running/complete/applied/failed/cancelled)",
|
|
372
|
+
)
|
|
373
|
+
.option("--json", "Output as JSON")
|
|
374
|
+
.action((options) => {
|
|
375
|
+
const values = Object.values(RUN_STATUS_V2);
|
|
376
|
+
if (options.json) console.log(JSON.stringify(values, null, 2));
|
|
377
|
+
else for (const v of values) logger.log(` ${chalk.cyan(v)}`);
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
rep
|
|
381
|
+
.command("v2-objectives")
|
|
382
|
+
.description("List V2 objectives (frozen enum)")
|
|
383
|
+
.option("--json", "Output as JSON")
|
|
384
|
+
.action((options) => {
|
|
385
|
+
const values = Object.values(OBJECTIVE_V2);
|
|
386
|
+
if (options.json) console.log(JSON.stringify(values, null, 2));
|
|
387
|
+
else for (const v of values) logger.log(` ${chalk.cyan(v)}`);
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
rep
|
|
391
|
+
.command("decay-models")
|
|
392
|
+
.description("List V2 decay models (frozen enum)")
|
|
393
|
+
.option("--json", "Output as JSON")
|
|
394
|
+
.action((options) => {
|
|
395
|
+
const values = Object.values(DECAY_MODEL_V2);
|
|
396
|
+
if (options.json) console.log(JSON.stringify(values, null, 2));
|
|
397
|
+
else for (const v of values) logger.log(` ${chalk.cyan(v)}`);
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
rep
|
|
401
|
+
.command("anomaly-methods")
|
|
402
|
+
.description("List V2 anomaly methods (frozen enum)")
|
|
403
|
+
.option("--json", "Output as JSON")
|
|
404
|
+
.action((options) => {
|
|
405
|
+
const values = Object.values(ANOMALY_METHOD_V2);
|
|
406
|
+
if (options.json) console.log(JSON.stringify(values, null, 2));
|
|
407
|
+
else for (const v of values) logger.log(` ${chalk.cyan(v)}`);
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
rep
|
|
411
|
+
.command("default-max-concurrent")
|
|
412
|
+
.description("Show default max concurrent optimizations")
|
|
413
|
+
.action(() => {
|
|
414
|
+
logger.log(` ${REPUTATION_DEFAULT_MAX_CONCURRENT}`);
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
rep
|
|
418
|
+
.command("max-concurrent")
|
|
419
|
+
.description("Show current max concurrent optimizations")
|
|
420
|
+
.action(() => {
|
|
421
|
+
logger.log(` ${getMaxConcurrentOptimizations()}`);
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
rep
|
|
425
|
+
.command("active-optimization-count")
|
|
426
|
+
.description("Show count of currently-RUNNING optimizations")
|
|
427
|
+
.action(() => {
|
|
428
|
+
logger.log(` ${getActiveOptimizationCount()}`);
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
rep
|
|
432
|
+
.command("set-max-concurrent <n>")
|
|
433
|
+
.description("Set the concurrency cap for RUNNING optimizations")
|
|
434
|
+
.action((n) => {
|
|
435
|
+
try {
|
|
436
|
+
const v = setMaxConcurrentOptimizations(Number(n));
|
|
437
|
+
logger.success(`Max concurrent = ${v}`);
|
|
438
|
+
} catch (err) {
|
|
439
|
+
logger.error(`Failed: ${err.message}`);
|
|
440
|
+
process.exit(1);
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
rep
|
|
445
|
+
.command("start-v2")
|
|
446
|
+
.description(
|
|
447
|
+
"Start a V2 optimization (RUNNING only, driven by complete/cancel/fail)",
|
|
448
|
+
)
|
|
449
|
+
.option(
|
|
450
|
+
"-o, --objective <name>",
|
|
451
|
+
"Objective (accuracy|fairness|resilience|convergence_speed)",
|
|
452
|
+
"accuracy",
|
|
453
|
+
)
|
|
454
|
+
.option("-i, --iterations <n>", "Iteration count", parseInt, 50)
|
|
455
|
+
.option("--json", "Output as JSON")
|
|
456
|
+
.action(async (options) => {
|
|
457
|
+
try {
|
|
458
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
459
|
+
const db = _dbFromCtx(ctx);
|
|
460
|
+
const run = startOptimizationV2(db, {
|
|
461
|
+
objective: options.objective,
|
|
462
|
+
iterations: options.iterations,
|
|
463
|
+
});
|
|
464
|
+
if (options.json) console.log(JSON.stringify(run, null, 2));
|
|
465
|
+
else {
|
|
466
|
+
logger.success(`Optimization started [${run.status}]`);
|
|
467
|
+
logger.log(` ${chalk.bold("Run ID:")} ${chalk.cyan(run.runId)}`);
|
|
468
|
+
logger.log(` ${chalk.bold("Objective:")} ${run.objective}`);
|
|
469
|
+
logger.log(` ${chalk.bold("Iterations:")} ${run.iterations}`);
|
|
470
|
+
}
|
|
471
|
+
await shutdown();
|
|
472
|
+
} catch (err) {
|
|
473
|
+
logger.error(`Failed: ${err.message}`);
|
|
474
|
+
process.exit(1);
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
rep
|
|
479
|
+
.command("complete <run-id>")
|
|
480
|
+
.description(
|
|
481
|
+
"Complete a V2 optimization (RUNNING → COMPLETE, runs iterations)",
|
|
482
|
+
)
|
|
483
|
+
.option("--json", "Output as JSON")
|
|
484
|
+
.action(async (runId, options) => {
|
|
485
|
+
try {
|
|
486
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
487
|
+
const db = _dbFromCtx(ctx);
|
|
488
|
+
const result = completeOptimization(db, runId);
|
|
489
|
+
if (options.json) console.log(JSON.stringify(result, null, 2));
|
|
490
|
+
else {
|
|
491
|
+
logger.success(`Completed [${result.status}]`);
|
|
492
|
+
logger.log(` ${chalk.bold("Best score:")} ${result.bestScore}`);
|
|
493
|
+
logger.log(
|
|
494
|
+
` ${chalk.bold("Best params:")} ${JSON.stringify(result.bestParams)}`,
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
await shutdown();
|
|
498
|
+
} catch (err) {
|
|
499
|
+
logger.error(`Failed: ${err.message}`);
|
|
500
|
+
process.exit(1);
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
rep
|
|
505
|
+
.command("cancel <run-id>")
|
|
506
|
+
.description("Cancel a V2 RUNNING optimization")
|
|
507
|
+
.action(async (runId) => {
|
|
508
|
+
try {
|
|
509
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
510
|
+
const db = _dbFromCtx(ctx);
|
|
511
|
+
const result = cancelOptimization(db, runId);
|
|
512
|
+
logger.success(`Cancelled [${result.status}]`);
|
|
513
|
+
await shutdown();
|
|
514
|
+
} catch (err) {
|
|
515
|
+
logger.error(`Failed: ${err.message}`);
|
|
516
|
+
process.exit(1);
|
|
517
|
+
}
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
rep
|
|
521
|
+
.command("fail <run-id>")
|
|
522
|
+
.description("Fail a V2 RUNNING optimization")
|
|
523
|
+
.option("--message <msg>", "Error message")
|
|
524
|
+
.action(async (runId, options) => {
|
|
525
|
+
try {
|
|
526
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
527
|
+
const db = _dbFromCtx(ctx);
|
|
528
|
+
const result = failOptimization(db, runId, options.message);
|
|
529
|
+
logger.success(`Failed [${result.status}]`);
|
|
530
|
+
if (result.errorMessage)
|
|
531
|
+
logger.log(` ${chalk.bold("Error:")} ${result.errorMessage}`);
|
|
532
|
+
await shutdown();
|
|
533
|
+
} catch (err) {
|
|
534
|
+
logger.error(`Failed: ${err.message}`);
|
|
535
|
+
process.exit(1);
|
|
536
|
+
}
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
rep
|
|
540
|
+
.command("apply-v2 <run-id>")
|
|
541
|
+
.description("Apply a V2 COMPLETE optimization (COMPLETE → APPLIED)")
|
|
542
|
+
.action(async (runId) => {
|
|
543
|
+
try {
|
|
544
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
545
|
+
const db = _dbFromCtx(ctx);
|
|
546
|
+
const result = applyOptimization(db, runId);
|
|
547
|
+
logger.success(`Applied [${result.status}]`);
|
|
548
|
+
await shutdown();
|
|
549
|
+
} catch (err) {
|
|
550
|
+
logger.error(`Failed: ${err.message}`);
|
|
551
|
+
process.exit(1);
|
|
552
|
+
}
|
|
553
|
+
});
|
|
554
|
+
|
|
555
|
+
rep
|
|
556
|
+
.command("set-status <run-id> <status>")
|
|
557
|
+
.description("Set V2 run status via the state machine")
|
|
558
|
+
.option("--message <msg>", "Error message (FAILED only)")
|
|
559
|
+
.option("--json", "Output as JSON")
|
|
560
|
+
.action(async (runId, status, options) => {
|
|
561
|
+
try {
|
|
562
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
563
|
+
const db = _dbFromCtx(ctx);
|
|
564
|
+
const patch = options.message ? { errorMessage: options.message } : {};
|
|
565
|
+
const result = setRunStatus(db, runId, status, patch);
|
|
566
|
+
if (options.json) console.log(JSON.stringify(result, null, 2));
|
|
567
|
+
else logger.success(`Status = ${result.status}`);
|
|
568
|
+
await shutdown();
|
|
569
|
+
} catch (err) {
|
|
570
|
+
logger.error(`Failed: ${err.message}`);
|
|
571
|
+
process.exit(1);
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
|
|
575
|
+
rep
|
|
576
|
+
.command("stats-v2")
|
|
577
|
+
.description("V2 aggregated stats")
|
|
578
|
+
.option("--json", "Output as JSON")
|
|
579
|
+
.action(async (options) => {
|
|
580
|
+
try {
|
|
581
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
582
|
+
_dbFromCtx(ctx);
|
|
583
|
+
const stats = getReputationStatsV2();
|
|
584
|
+
if (options.json) console.log(JSON.stringify(stats, null, 2));
|
|
585
|
+
else {
|
|
586
|
+
logger.log(` ${chalk.bold("Total runs:")} ${stats.totalRuns}`);
|
|
587
|
+
logger.log(` ${chalk.bold("Active:")} ${stats.activeRuns}`);
|
|
588
|
+
logger.log(
|
|
589
|
+
` ${chalk.bold("Max concurrent:")} ${stats.maxConcurrentOptimizations}`,
|
|
590
|
+
);
|
|
591
|
+
logger.log(` ${chalk.bold("By status:")}`);
|
|
592
|
+
for (const [k, v] of Object.entries(stats.byStatus))
|
|
593
|
+
logger.log(` ${k.padEnd(12)} ${v}`);
|
|
594
|
+
logger.log(` ${chalk.bold("By objective:")}`);
|
|
595
|
+
for (const [k, v] of Object.entries(stats.byObjective))
|
|
596
|
+
logger.log(` ${k.padEnd(20)} ${v}`);
|
|
597
|
+
logger.log(
|
|
598
|
+
` ${chalk.bold("Observations:")} ${stats.observations.totalObservations} (${stats.observations.totalDids} DIDs)`,
|
|
599
|
+
);
|
|
600
|
+
logger.log(
|
|
601
|
+
` ${chalk.bold("Best score ever:")} ${stats.bestScoreEver}`,
|
|
602
|
+
);
|
|
603
|
+
}
|
|
604
|
+
await shutdown();
|
|
605
|
+
} catch (err) {
|
|
606
|
+
logger.error(`Failed: ${err.message}`);
|
|
607
|
+
process.exit(1);
|
|
608
|
+
}
|
|
609
|
+
});
|
|
349
610
|
}
|