chainlesschain 0.66.0 → 0.132.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/bin/chainlesschain.js +0 -0
- package/package.json +1 -1
- package/src/commands/a2a.js +380 -0
- package/src/commands/agent-network.js +254 -1
- package/src/commands/audit.js +302 -0
- package/src/commands/automation.js +271 -1
- package/src/commands/bi.js +348 -0
- package/src/commands/codegen.js +224 -0
- package/src/commands/collab.js +341 -0
- package/src/commands/compliance.js +1035 -0
- package/src/commands/cowork.js +221 -0
- package/src/commands/crosschain.js +218 -0
- package/src/commands/dbevo.js +284 -0
- package/src/commands/dev.js +252 -0
- package/src/commands/did.js +358 -0
- package/src/commands/dlp.js +341 -0
- package/src/commands/encrypt.js +341 -0
- package/src/commands/evomap.js +394 -0
- package/src/commands/export.js +256 -1
- package/src/commands/federation.js +283 -0
- package/src/commands/fusion.js +258 -0
- package/src/commands/governance.js +325 -0
- package/src/commands/hardening.js +411 -0
- package/src/commands/hook.js +148 -0
- package/src/commands/import.js +252 -0
- package/src/commands/incentive.js +322 -0
- package/src/commands/inference.js +318 -0
- package/src/commands/infra.js +244 -0
- package/src/commands/instinct.js +260 -0
- package/src/commands/ipfs.js +318 -0
- package/src/commands/kg.js +387 -0
- package/src/commands/llm.js +263 -0
- package/src/commands/lowcode.js +356 -0
- package/src/commands/marketplace.js +256 -0
- package/src/commands/mcp.js +221 -0
- package/src/commands/memory.js +248 -0
- package/src/commands/multimodal.js +296 -0
- package/src/commands/nlprog.js +356 -0
- package/src/commands/note.js +244 -0
- package/src/commands/ops.js +354 -0
- package/src/commands/orchestrate.js +166 -0
- package/src/commands/org.js +277 -0
- package/src/commands/p2p.js +390 -0
- package/src/commands/perception.js +290 -0
- package/src/commands/permmem.js +251 -0
- package/src/commands/plugin-ecosystem.js +273 -0
- package/src/commands/pqc.js +393 -0
- package/src/commands/privacy.js +321 -0
- package/src/commands/quantization.js +351 -0
- package/src/commands/rcache.js +271 -0
- package/src/commands/recommend.js +340 -0
- package/src/commands/reputation.js +261 -0
- package/src/commands/runtime.js +307 -0
- package/src/commands/scim.js +262 -0
- package/src/commands/session.js +258 -0
- package/src/commands/siem.js +246 -0
- package/src/commands/skill.js +267 -1
- package/src/commands/sla.js +259 -0
- package/src/commands/social.js +256 -0
- package/src/commands/sso.js +186 -1
- package/src/commands/stress.js +230 -0
- package/src/commands/sync.js +256 -0
- package/src/commands/tech.js +338 -0
- package/src/commands/tenant.js +351 -0
- package/src/commands/terraform.js +245 -0
- package/src/commands/tokens.js +269 -0
- package/src/commands/trust.js +249 -0
- package/src/commands/wallet.js +277 -0
- package/src/commands/workflow.js +171 -0
- package/src/commands/zkp.js +335 -0
- package/src/index.js +4 -0
- package/src/lib/a2a-protocol.js +451 -0
- package/src/lib/agent-coordinator.js +325 -0
- package/src/lib/agent-network.js +387 -0
- package/src/lib/agent-router.js +395 -0
- package/src/lib/aiops.js +478 -0
- package/src/lib/app-builder.js +239 -0
- package/src/lib/audit-logger.js +379 -0
- package/src/lib/automation-engine.js +330 -0
- package/src/lib/autonomous-developer.js +350 -0
- package/src/lib/bi-engine.js +338 -0
- package/src/lib/code-agent.js +323 -0
- package/src/lib/collaboration-governance.js +364 -0
- package/src/lib/community-governance.js +436 -0
- package/src/lib/compliance-manager.js +434 -0
- package/src/lib/content-recommendation.js +469 -0
- package/src/lib/cross-chain.js +345 -0
- package/src/lib/crypto-manager.js +350 -0
- package/src/lib/dbevo.js +338 -0
- package/src/lib/decentral-infra.js +340 -0
- package/src/lib/did-manager.js +367 -0
- package/src/lib/dlp-engine.js +389 -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/hardening-manager.js +348 -0
- package/src/lib/hook-manager.js +380 -0
- package/src/lib/inference-network.js +330 -0
- package/src/lib/instinct-manager.js +332 -0
- package/src/lib/ipfs-storage.js +334 -0
- package/src/lib/knowledge-exporter.js +381 -0
- package/src/lib/knowledge-graph.js +432 -0
- package/src/lib/knowledge-importer.js +379 -0
- package/src/lib/llm-providers.js +391 -0
- package/src/lib/mcp-registry.js +333 -0
- package/src/lib/memory-manager.js +330 -0
- package/src/lib/multimodal.js +346 -0
- package/src/lib/nl-programming.js +343 -0
- package/src/lib/note-versioning.js +327 -0
- package/src/lib/org-manager.js +323 -0
- package/src/lib/p2p-manager.js +387 -0
- package/src/lib/perception.js +346 -0
- package/src/lib/perf-tuning.js +4 -1
- package/src/lib/permanent-memory.js +320 -0
- package/src/lib/plugin-ecosystem.js +377 -0
- package/src/lib/pqc-manager.js +368 -0
- package/src/lib/privacy-computing.js +427 -0
- package/src/lib/protocol-fusion.js +417 -0
- package/src/lib/quantization.js +325 -0
- package/src/lib/reputation-optimizer.js +299 -0
- package/src/lib/response-cache.js +327 -0
- package/src/lib/scim-manager.js +329 -0
- package/src/lib/session-manager.js +329 -0
- package/src/lib/siem-exporter.js +333 -0
- package/src/lib/skill-loader.js +377 -0
- package/src/lib/skill-marketplace.js +325 -0
- package/src/lib/sla-manager.js +275 -0
- package/src/lib/social-manager.js +326 -0
- package/src/lib/sso-manager.js +332 -0
- package/src/lib/stress-tester.js +330 -0
- package/src/lib/sync-manager.js +326 -0
- package/src/lib/tech-learning-engine.js +369 -0
- package/src/lib/tenant-saas.js +460 -0
- package/src/lib/terraform-manager.js +363 -0
- package/src/lib/threat-intel.js +335 -0
- package/src/lib/token-incentive.js +293 -0
- package/src/lib/token-tracker.js +329 -0
- package/src/lib/trust-security.js +390 -0
- package/src/lib/ueba.js +389 -0
- package/src/lib/universal-runtime.js +325 -0
- package/src/lib/wallet-manager.js +326 -0
- package/src/lib/workflow-engine.js +322 -0
- package/src/lib/zkp-engine.js +274 -0
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
|
}
|
|
@@ -20,8 +20,51 @@ import {
|
|
|
20
20
|
cancelJob,
|
|
21
21
|
deleteJob,
|
|
22
22
|
getQuantizationStats,
|
|
23
|
+
/* V2 (Phase 20) */
|
|
24
|
+
MODEL_MATURITY_V2,
|
|
25
|
+
JOB_TICKET_V2,
|
|
26
|
+
getDefaultMaxActiveModelsPerOwnerV2,
|
|
27
|
+
getMaxActiveModelsPerOwnerV2,
|
|
28
|
+
setMaxActiveModelsPerOwnerV2,
|
|
29
|
+
getDefaultMaxRunningJobsPerOwnerV2,
|
|
30
|
+
getMaxRunningJobsPerOwnerV2,
|
|
31
|
+
setMaxRunningJobsPerOwnerV2,
|
|
32
|
+
getDefaultModelIdleMsV2,
|
|
33
|
+
getModelIdleMsV2,
|
|
34
|
+
setModelIdleMsV2,
|
|
35
|
+
getDefaultJobStuckMsV2,
|
|
36
|
+
getJobStuckMsV2,
|
|
37
|
+
setJobStuckMsV2,
|
|
38
|
+
registerModelV2,
|
|
39
|
+
getModelV2,
|
|
40
|
+
setModelMaturityV2,
|
|
41
|
+
activateModel,
|
|
42
|
+
deprecateModel,
|
|
43
|
+
retireModel,
|
|
44
|
+
touchModelUsage,
|
|
45
|
+
enqueueJobTicketV2,
|
|
46
|
+
getJobTicketV2,
|
|
47
|
+
setJobTicketStatusV2,
|
|
48
|
+
startJobTicket,
|
|
49
|
+
completeJobTicket,
|
|
50
|
+
failJobTicket,
|
|
51
|
+
cancelJobTicket,
|
|
52
|
+
getActiveModelCount,
|
|
53
|
+
getRunningJobCount,
|
|
54
|
+
autoRetireIdleModels,
|
|
55
|
+
autoFailStuckJobTickets,
|
|
56
|
+
getQuantizationStatsV2,
|
|
23
57
|
} from "../lib/quantization.js";
|
|
24
58
|
|
|
59
|
+
function _parseMetaV2(s) {
|
|
60
|
+
if (!s) return undefined;
|
|
61
|
+
try {
|
|
62
|
+
return JSON.parse(s);
|
|
63
|
+
} catch {
|
|
64
|
+
throw new Error(`--metadata must be valid JSON`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
25
68
|
function _dbFromCtx(cmd) {
|
|
26
69
|
const root = cmd?.parent?.parent ?? cmd?.parent;
|
|
27
70
|
return root?._db;
|
|
@@ -276,5 +319,313 @@ export function registerQuantizationCommand(program) {
|
|
|
276
319
|
console.log(`Avg duration: ${s.avgDurationMs}ms`);
|
|
277
320
|
});
|
|
278
321
|
|
|
322
|
+
/* ═════════════════════════════════════════════════════ *
|
|
323
|
+
* Phase 20 V2 — Model Maturity + Job Ticket Lifecycle
|
|
324
|
+
* ═════════════════════════════════════════════════════ */
|
|
325
|
+
|
|
326
|
+
quant
|
|
327
|
+
.command("model-maturities-v2")
|
|
328
|
+
.description("List Phase 20 V2 model maturity states")
|
|
329
|
+
.option("--json", "JSON output")
|
|
330
|
+
.action((opts) => {
|
|
331
|
+
const v = Object.values(MODEL_MATURITY_V2);
|
|
332
|
+
if (opts.json) return console.log(JSON.stringify(v, null, 2));
|
|
333
|
+
for (const s of v) console.log(s);
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
quant
|
|
337
|
+
.command("job-ticket-lifecycles-v2")
|
|
338
|
+
.description("List Phase 20 V2 job-ticket lifecycle states")
|
|
339
|
+
.option("--json", "JSON output")
|
|
340
|
+
.action((opts) => {
|
|
341
|
+
const v = Object.values(JOB_TICKET_V2);
|
|
342
|
+
if (opts.json) return console.log(JSON.stringify(v, null, 2));
|
|
343
|
+
for (const s of v) console.log(s);
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
quant
|
|
347
|
+
.command("default-max-active-models-per-owner")
|
|
348
|
+
.description("Show default V2 per-owner active-model cap")
|
|
349
|
+
.action(() => console.log(getDefaultMaxActiveModelsPerOwnerV2()));
|
|
350
|
+
|
|
351
|
+
quant
|
|
352
|
+
.command("max-active-models-per-owner")
|
|
353
|
+
.description("Show current V2 per-owner active-model cap")
|
|
354
|
+
.action(() => console.log(getMaxActiveModelsPerOwnerV2()));
|
|
355
|
+
|
|
356
|
+
quant
|
|
357
|
+
.command("set-max-active-models-per-owner <n>")
|
|
358
|
+
.description("Set V2 per-owner active-model cap")
|
|
359
|
+
.action((n) => console.log(setMaxActiveModelsPerOwnerV2(n)));
|
|
360
|
+
|
|
361
|
+
quant
|
|
362
|
+
.command("default-max-running-jobs-per-owner")
|
|
363
|
+
.description("Show default V2 per-owner running-job cap")
|
|
364
|
+
.action(() => console.log(getDefaultMaxRunningJobsPerOwnerV2()));
|
|
365
|
+
|
|
366
|
+
quant
|
|
367
|
+
.command("max-running-jobs-per-owner")
|
|
368
|
+
.description("Show current V2 per-owner running-job cap")
|
|
369
|
+
.action(() => console.log(getMaxRunningJobsPerOwnerV2()));
|
|
370
|
+
|
|
371
|
+
quant
|
|
372
|
+
.command("set-max-running-jobs-per-owner <n>")
|
|
373
|
+
.description("Set V2 per-owner running-job cap")
|
|
374
|
+
.action((n) => console.log(setMaxRunningJobsPerOwnerV2(n)));
|
|
375
|
+
|
|
376
|
+
quant
|
|
377
|
+
.command("default-model-idle-ms")
|
|
378
|
+
.description("Show default V2 model-idle threshold")
|
|
379
|
+
.action(() => console.log(getDefaultModelIdleMsV2()));
|
|
380
|
+
|
|
381
|
+
quant
|
|
382
|
+
.command("model-idle-ms")
|
|
383
|
+
.description("Show current V2 model-idle threshold")
|
|
384
|
+
.action(() => console.log(getModelIdleMsV2()));
|
|
385
|
+
|
|
386
|
+
quant
|
|
387
|
+
.command("set-model-idle-ms <ms>")
|
|
388
|
+
.description("Set V2 model-idle threshold (ms)")
|
|
389
|
+
.action((ms) => console.log(setModelIdleMsV2(ms)));
|
|
390
|
+
|
|
391
|
+
quant
|
|
392
|
+
.command("default-job-stuck-ms")
|
|
393
|
+
.description("Show default V2 job-stuck threshold")
|
|
394
|
+
.action(() => console.log(getDefaultJobStuckMsV2()));
|
|
395
|
+
|
|
396
|
+
quant
|
|
397
|
+
.command("job-stuck-ms")
|
|
398
|
+
.description("Show current V2 job-stuck threshold")
|
|
399
|
+
.action(() => console.log(getJobStuckMsV2()));
|
|
400
|
+
|
|
401
|
+
quant
|
|
402
|
+
.command("set-job-stuck-ms <ms>")
|
|
403
|
+
.description("Set V2 job-stuck threshold (ms)")
|
|
404
|
+
.action((ms) => console.log(setJobStuckMsV2(ms)));
|
|
405
|
+
|
|
406
|
+
quant
|
|
407
|
+
.command("active-model-count")
|
|
408
|
+
.description("Count active V2 models (optionally scoped by owner)")
|
|
409
|
+
.option("-o, --owner <id>", "Owner ID")
|
|
410
|
+
.action((opts) => console.log(getActiveModelCount(opts.owner)));
|
|
411
|
+
|
|
412
|
+
quant
|
|
413
|
+
.command("running-job-count")
|
|
414
|
+
.description("Count running V2 job tickets (optionally scoped by owner)")
|
|
415
|
+
.option("-o, --owner <id>", "Owner ID")
|
|
416
|
+
.action((opts) => console.log(getRunningJobCount(opts.owner)));
|
|
417
|
+
|
|
418
|
+
quant
|
|
419
|
+
.command("register-model-v2 <model-id>")
|
|
420
|
+
.description("Register a V2 model")
|
|
421
|
+
.requiredOption("-o, --owner <id>", "Owner ID")
|
|
422
|
+
.option("-f, --family <name>", "Model family (e.g. llama)")
|
|
423
|
+
.option("-i, --initial-status <status>", "Initial status")
|
|
424
|
+
.option("-m, --metadata <json>", "Metadata JSON")
|
|
425
|
+
.option("--json", "JSON output")
|
|
426
|
+
.action((modelId, opts) => {
|
|
427
|
+
const db = _dbFromCtx(quant);
|
|
428
|
+
const rec = registerModelV2(db, {
|
|
429
|
+
modelId,
|
|
430
|
+
ownerId: opts.owner,
|
|
431
|
+
family: opts.family,
|
|
432
|
+
initialStatus: opts.initialStatus,
|
|
433
|
+
metadata: _parseMetaV2(opts.metadata),
|
|
434
|
+
});
|
|
435
|
+
if (opts.json) return console.log(JSON.stringify(rec, null, 2));
|
|
436
|
+
console.log(`Registered model ${modelId} (${rec.status})`);
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
quant
|
|
440
|
+
.command("model-v2 <model-id>")
|
|
441
|
+
.description("Show a V2 model")
|
|
442
|
+
.option("--json", "JSON output")
|
|
443
|
+
.action((id, opts) => {
|
|
444
|
+
const rec = getModelV2(id);
|
|
445
|
+
if (!rec) {
|
|
446
|
+
console.error(`Unknown model: ${id}`);
|
|
447
|
+
process.exitCode = 1;
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
if (opts.json) return console.log(JSON.stringify(rec, null, 2));
|
|
451
|
+
console.log(`${rec.modelId} [${rec.status}] owner=${rec.ownerId}`);
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
quant
|
|
455
|
+
.command("set-model-maturity-v2 <model-id> <status>")
|
|
456
|
+
.description("Transition V2 model maturity")
|
|
457
|
+
.option("-r, --reason <text>", "Reason")
|
|
458
|
+
.option("-m, --metadata <json>", "Metadata patch (JSON)")
|
|
459
|
+
.action((id, status, opts) => {
|
|
460
|
+
const db = _dbFromCtx(quant);
|
|
461
|
+
const rec = setModelMaturityV2(db, id, status, {
|
|
462
|
+
reason: opts.reason,
|
|
463
|
+
metadata: _parseMetaV2(opts.metadata),
|
|
464
|
+
});
|
|
465
|
+
console.log(`${id} → ${rec.status}`);
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
quant
|
|
469
|
+
.command("activate-model <model-id>")
|
|
470
|
+
.description("Transition a V2 model to ACTIVE")
|
|
471
|
+
.option("-r, --reason <text>", "Reason")
|
|
472
|
+
.action((id, opts) => {
|
|
473
|
+
const rec = activateModel(_dbFromCtx(quant), id, opts.reason);
|
|
474
|
+
console.log(`${id} → ${rec.status}`);
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
quant
|
|
478
|
+
.command("deprecate-model <model-id>")
|
|
479
|
+
.description("Transition a V2 model to DEPRECATED")
|
|
480
|
+
.option("-r, --reason <text>", "Reason")
|
|
481
|
+
.action((id, opts) => {
|
|
482
|
+
const rec = deprecateModel(_dbFromCtx(quant), id, opts.reason);
|
|
483
|
+
console.log(`${id} → ${rec.status}`);
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
quant
|
|
487
|
+
.command("retire-model <model-id>")
|
|
488
|
+
.description("Transition a V2 model to RETIRED")
|
|
489
|
+
.option("-r, --reason <text>", "Reason")
|
|
490
|
+
.action((id, opts) => {
|
|
491
|
+
const rec = retireModel(_dbFromCtx(quant), id, opts.reason);
|
|
492
|
+
console.log(`${id} → ${rec.status}`);
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
quant
|
|
496
|
+
.command("touch-model-usage <model-id>")
|
|
497
|
+
.description("Bump lastUsedAt for a V2 model")
|
|
498
|
+
.action((id) => {
|
|
499
|
+
const rec = touchModelUsage(id);
|
|
500
|
+
console.log(`${id} lastUsedAt=${rec.lastUsedAt}`);
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
quant
|
|
504
|
+
.command("enqueue-job-ticket-v2 <ticket-id>")
|
|
505
|
+
.description("Enqueue a V2 quantization job ticket")
|
|
506
|
+
.requiredOption("-o, --owner <id>", "Owner ID")
|
|
507
|
+
.requiredOption("-M, --model <id>", "Model ID")
|
|
508
|
+
.requiredOption("-t, --quant-type <type>", "Quant type (gguf/gptq)")
|
|
509
|
+
.option("-l, --level <lvl>", "Level (e.g. Q4_K_M)")
|
|
510
|
+
.option("-m, --metadata <json>", "Metadata JSON")
|
|
511
|
+
.option("--json", "JSON output")
|
|
512
|
+
.action((ticketId, opts) => {
|
|
513
|
+
const db = _dbFromCtx(quant);
|
|
514
|
+
const rec = enqueueJobTicketV2(db, {
|
|
515
|
+
ticketId,
|
|
516
|
+
ownerId: opts.owner,
|
|
517
|
+
modelId: opts.model,
|
|
518
|
+
quantType: opts.quantType,
|
|
519
|
+
level: opts.level,
|
|
520
|
+
metadata: _parseMetaV2(opts.metadata),
|
|
521
|
+
});
|
|
522
|
+
if (opts.json) return console.log(JSON.stringify(rec, null, 2));
|
|
523
|
+
console.log(`Enqueued ticket ${ticketId} (${rec.status})`);
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
quant
|
|
527
|
+
.command("job-ticket-v2 <ticket-id>")
|
|
528
|
+
.description("Show a V2 job ticket")
|
|
529
|
+
.option("--json", "JSON output")
|
|
530
|
+
.action((id, opts) => {
|
|
531
|
+
const rec = getJobTicketV2(id);
|
|
532
|
+
if (!rec) {
|
|
533
|
+
console.error(`Unknown ticket: ${id}`);
|
|
534
|
+
process.exitCode = 1;
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
if (opts.json) return console.log(JSON.stringify(rec, null, 2));
|
|
538
|
+
console.log(`${rec.ticketId} [${rec.status}] owner=${rec.ownerId}`);
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
quant
|
|
542
|
+
.command("set-job-ticket-status-v2 <ticket-id> <status>")
|
|
543
|
+
.description("Transition V2 job ticket status")
|
|
544
|
+
.option("-r, --reason <text>", "Reason")
|
|
545
|
+
.option("-m, --metadata <json>", "Metadata patch (JSON)")
|
|
546
|
+
.action((id, status, opts) => {
|
|
547
|
+
const db = _dbFromCtx(quant);
|
|
548
|
+
const rec = setJobTicketStatusV2(db, id, status, {
|
|
549
|
+
reason: opts.reason,
|
|
550
|
+
metadata: _parseMetaV2(opts.metadata),
|
|
551
|
+
});
|
|
552
|
+
console.log(`${id} → ${rec.status}`);
|
|
553
|
+
});
|
|
554
|
+
|
|
555
|
+
quant
|
|
556
|
+
.command("start-job-ticket <ticket-id>")
|
|
557
|
+
.description("Transition a V2 job ticket to RUNNING")
|
|
558
|
+
.option("-r, --reason <text>", "Reason")
|
|
559
|
+
.action((id, opts) => {
|
|
560
|
+
const rec = startJobTicket(_dbFromCtx(quant), id, opts.reason);
|
|
561
|
+
console.log(`${id} → ${rec.status}`);
|
|
562
|
+
});
|
|
563
|
+
|
|
564
|
+
quant
|
|
565
|
+
.command("complete-job-ticket <ticket-id>")
|
|
566
|
+
.description("Transition a V2 job ticket to COMPLETED")
|
|
567
|
+
.option("-r, --reason <text>", "Reason")
|
|
568
|
+
.action((id, opts) => {
|
|
569
|
+
const rec = completeJobTicket(_dbFromCtx(quant), id, opts.reason);
|
|
570
|
+
console.log(`${id} → ${rec.status}`);
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
quant
|
|
574
|
+
.command("fail-job-ticket <ticket-id>")
|
|
575
|
+
.description("Transition a V2 job ticket to FAILED")
|
|
576
|
+
.option("-r, --reason <text>", "Reason")
|
|
577
|
+
.action((id, opts) => {
|
|
578
|
+
const rec = failJobTicket(_dbFromCtx(quant), id, opts.reason);
|
|
579
|
+
console.log(`${id} → ${rec.status}`);
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
quant
|
|
583
|
+
.command("cancel-job-ticket <ticket-id>")
|
|
584
|
+
.description("Transition a V2 job ticket to CANCELED")
|
|
585
|
+
.option("-r, --reason <text>", "Reason")
|
|
586
|
+
.action((id, opts) => {
|
|
587
|
+
const rec = cancelJobTicket(_dbFromCtx(quant), id, opts.reason);
|
|
588
|
+
console.log(`${id} → ${rec.status}`);
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
quant
|
|
592
|
+
.command("auto-retire-idle-models")
|
|
593
|
+
.description("Flip idle V2 models (active+deprecated) → RETIRED")
|
|
594
|
+
.option("--json", "JSON output")
|
|
595
|
+
.action((opts) => {
|
|
596
|
+
const r = autoRetireIdleModels(_dbFromCtx(quant));
|
|
597
|
+
if (opts.json) return console.log(JSON.stringify(r, null, 2));
|
|
598
|
+
console.log(`Retired ${r.count} idle model(s)`);
|
|
599
|
+
});
|
|
600
|
+
|
|
601
|
+
quant
|
|
602
|
+
.command("auto-fail-stuck-job-tickets")
|
|
603
|
+
.description("Flip stuck RUNNING V2 tickets → FAILED")
|
|
604
|
+
.option("--json", "JSON output")
|
|
605
|
+
.action((opts) => {
|
|
606
|
+
const r = autoFailStuckJobTickets(_dbFromCtx(quant));
|
|
607
|
+
if (opts.json) return console.log(JSON.stringify(r, null, 2));
|
|
608
|
+
console.log(`Failed ${r.count} stuck ticket(s)`);
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
quant
|
|
612
|
+
.command("stats-v2")
|
|
613
|
+
.description("Phase 20 V2 statistics")
|
|
614
|
+
.option("--json", "JSON output")
|
|
615
|
+
.action((opts) => {
|
|
616
|
+
const s = getQuantizationStatsV2();
|
|
617
|
+
if (opts.json) return console.log(JSON.stringify(s, null, 2));
|
|
618
|
+
console.log(
|
|
619
|
+
`Models(V2)=${s.totalModelsV2} Tickets(V2)=${s.totalTicketsV2} ` +
|
|
620
|
+
`caps: active-models/owner=${s.maxActiveModelsPerOwner} running-jobs/owner=${s.maxRunningJobsPerOwner}`,
|
|
621
|
+
);
|
|
622
|
+
console.log("models-by-status:");
|
|
623
|
+
for (const [k, v] of Object.entries(s.modelsByStatus))
|
|
624
|
+
console.log(` ${k.padEnd(12)} ${v}`);
|
|
625
|
+
console.log("tickets-by-status:");
|
|
626
|
+
for (const [k, v] of Object.entries(s.ticketsByStatus))
|
|
627
|
+
console.log(` ${k.padEnd(12)} ${v}`);
|
|
628
|
+
});
|
|
629
|
+
|
|
279
630
|
program.addCommand(quant);
|
|
280
631
|
}
|