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.
Files changed (143) hide show
  1. package/bin/chainlesschain.js +0 -0
  2. package/package.json +1 -1
  3. package/src/commands/a2a.js +380 -0
  4. package/src/commands/agent-network.js +254 -1
  5. package/src/commands/audit.js +302 -0
  6. package/src/commands/automation.js +271 -1
  7. package/src/commands/bi.js +348 -0
  8. package/src/commands/codegen.js +224 -0
  9. package/src/commands/collab.js +341 -0
  10. package/src/commands/compliance.js +1035 -0
  11. package/src/commands/cowork.js +221 -0
  12. package/src/commands/crosschain.js +218 -0
  13. package/src/commands/dbevo.js +284 -0
  14. package/src/commands/dev.js +252 -0
  15. package/src/commands/did.js +358 -0
  16. package/src/commands/dlp.js +341 -0
  17. package/src/commands/encrypt.js +341 -0
  18. package/src/commands/evomap.js +394 -0
  19. package/src/commands/export.js +256 -1
  20. package/src/commands/federation.js +283 -0
  21. package/src/commands/fusion.js +258 -0
  22. package/src/commands/governance.js +325 -0
  23. package/src/commands/hardening.js +411 -0
  24. package/src/commands/hook.js +148 -0
  25. package/src/commands/import.js +252 -0
  26. package/src/commands/incentive.js +322 -0
  27. package/src/commands/inference.js +318 -0
  28. package/src/commands/infra.js +244 -0
  29. package/src/commands/instinct.js +260 -0
  30. package/src/commands/ipfs.js +318 -0
  31. package/src/commands/kg.js +387 -0
  32. package/src/commands/llm.js +263 -0
  33. package/src/commands/lowcode.js +356 -0
  34. package/src/commands/marketplace.js +256 -0
  35. package/src/commands/mcp.js +221 -0
  36. package/src/commands/memory.js +248 -0
  37. package/src/commands/multimodal.js +296 -0
  38. package/src/commands/nlprog.js +356 -0
  39. package/src/commands/note.js +244 -0
  40. package/src/commands/ops.js +354 -0
  41. package/src/commands/orchestrate.js +166 -0
  42. package/src/commands/org.js +277 -0
  43. package/src/commands/p2p.js +390 -0
  44. package/src/commands/perception.js +290 -0
  45. package/src/commands/permmem.js +251 -0
  46. package/src/commands/plugin-ecosystem.js +273 -0
  47. package/src/commands/pqc.js +393 -0
  48. package/src/commands/privacy.js +321 -0
  49. package/src/commands/quantization.js +351 -0
  50. package/src/commands/rcache.js +271 -0
  51. package/src/commands/recommend.js +340 -0
  52. package/src/commands/reputation.js +261 -0
  53. package/src/commands/runtime.js +307 -0
  54. package/src/commands/scim.js +262 -0
  55. package/src/commands/session.js +258 -0
  56. package/src/commands/siem.js +246 -0
  57. package/src/commands/skill.js +267 -1
  58. package/src/commands/sla.js +259 -0
  59. package/src/commands/social.js +256 -0
  60. package/src/commands/sso.js +186 -1
  61. package/src/commands/stress.js +230 -0
  62. package/src/commands/sync.js +256 -0
  63. package/src/commands/tech.js +338 -0
  64. package/src/commands/tenant.js +351 -0
  65. package/src/commands/terraform.js +245 -0
  66. package/src/commands/tokens.js +269 -0
  67. package/src/commands/trust.js +249 -0
  68. package/src/commands/wallet.js +277 -0
  69. package/src/commands/workflow.js +171 -0
  70. package/src/commands/zkp.js +335 -0
  71. package/src/index.js +4 -0
  72. package/src/lib/a2a-protocol.js +451 -0
  73. package/src/lib/agent-coordinator.js +325 -0
  74. package/src/lib/agent-network.js +387 -0
  75. package/src/lib/agent-router.js +395 -0
  76. package/src/lib/aiops.js +478 -0
  77. package/src/lib/app-builder.js +239 -0
  78. package/src/lib/audit-logger.js +379 -0
  79. package/src/lib/automation-engine.js +330 -0
  80. package/src/lib/autonomous-developer.js +350 -0
  81. package/src/lib/bi-engine.js +338 -0
  82. package/src/lib/code-agent.js +323 -0
  83. package/src/lib/collaboration-governance.js +364 -0
  84. package/src/lib/community-governance.js +436 -0
  85. package/src/lib/compliance-manager.js +434 -0
  86. package/src/lib/content-recommendation.js +469 -0
  87. package/src/lib/cross-chain.js +345 -0
  88. package/src/lib/crypto-manager.js +350 -0
  89. package/src/lib/dbevo.js +338 -0
  90. package/src/lib/decentral-infra.js +340 -0
  91. package/src/lib/did-manager.js +367 -0
  92. package/src/lib/dlp-engine.js +389 -0
  93. package/src/lib/evomap-federation.js +177 -0
  94. package/src/lib/evomap-governance.js +276 -0
  95. package/src/lib/federation-hardening.js +259 -0
  96. package/src/lib/hardening-manager.js +348 -0
  97. package/src/lib/hook-manager.js +380 -0
  98. package/src/lib/inference-network.js +330 -0
  99. package/src/lib/instinct-manager.js +332 -0
  100. package/src/lib/ipfs-storage.js +334 -0
  101. package/src/lib/knowledge-exporter.js +381 -0
  102. package/src/lib/knowledge-graph.js +432 -0
  103. package/src/lib/knowledge-importer.js +379 -0
  104. package/src/lib/llm-providers.js +391 -0
  105. package/src/lib/mcp-registry.js +333 -0
  106. package/src/lib/memory-manager.js +330 -0
  107. package/src/lib/multimodal.js +346 -0
  108. package/src/lib/nl-programming.js +343 -0
  109. package/src/lib/note-versioning.js +327 -0
  110. package/src/lib/org-manager.js +323 -0
  111. package/src/lib/p2p-manager.js +387 -0
  112. package/src/lib/perception.js +346 -0
  113. package/src/lib/perf-tuning.js +4 -1
  114. package/src/lib/permanent-memory.js +320 -0
  115. package/src/lib/plugin-ecosystem.js +377 -0
  116. package/src/lib/pqc-manager.js +368 -0
  117. package/src/lib/privacy-computing.js +427 -0
  118. package/src/lib/protocol-fusion.js +417 -0
  119. package/src/lib/quantization.js +325 -0
  120. package/src/lib/reputation-optimizer.js +299 -0
  121. package/src/lib/response-cache.js +327 -0
  122. package/src/lib/scim-manager.js +329 -0
  123. package/src/lib/session-manager.js +329 -0
  124. package/src/lib/siem-exporter.js +333 -0
  125. package/src/lib/skill-loader.js +377 -0
  126. package/src/lib/skill-marketplace.js +325 -0
  127. package/src/lib/sla-manager.js +275 -0
  128. package/src/lib/social-manager.js +326 -0
  129. package/src/lib/sso-manager.js +332 -0
  130. package/src/lib/stress-tester.js +330 -0
  131. package/src/lib/sync-manager.js +326 -0
  132. package/src/lib/tech-learning-engine.js +369 -0
  133. package/src/lib/tenant-saas.js +460 -0
  134. package/src/lib/terraform-manager.js +363 -0
  135. package/src/lib/threat-intel.js +335 -0
  136. package/src/lib/token-incentive.js +293 -0
  137. package/src/lib/token-tracker.js +329 -0
  138. package/src/lib/trust-security.js +390 -0
  139. package/src/lib/ueba.js +389 -0
  140. package/src/lib/universal-runtime.js +325 -0
  141. package/src/lib/wallet-manager.js +326 -0
  142. package/src/lib/workflow-engine.js +322 -0
  143. package/src/lib/zkp-engine.js +274 -0
@@ -281,10 +281,444 @@ export function checkAccess(resource, action, role) {
281
281
  };
282
282
  }
283
283
 
284
+ /* ═══════════════════════════════════════════════════════════════
285
+ V2 SURFACE (Phase 19 canonical) — strictly additive
286
+ ═══════════════════════════════════════════════════════════════ */
287
+
288
+ export const EVIDENCE_STATUS_V2 = Object.freeze({
289
+ COLLECTED: "collected",
290
+ VERIFIED: "verified",
291
+ REJECTED: "rejected",
292
+ EXPIRED: "expired",
293
+ });
294
+
295
+ export const POLICY_STATUS_V2 = Object.freeze({
296
+ DRAFT: "draft",
297
+ ACTIVE: "active",
298
+ SUSPENDED: "suspended",
299
+ DEPRECATED: "deprecated",
300
+ });
301
+
302
+ export const REPORT_STATUS_V2 = Object.freeze({
303
+ PENDING: "pending",
304
+ GENERATING: "generating",
305
+ PUBLISHED: "published",
306
+ ARCHIVED: "archived",
307
+ });
308
+
309
+ export const SEVERITY_V2 = Object.freeze({
310
+ CRITICAL: "critical",
311
+ HIGH: "high",
312
+ MEDIUM: "medium",
313
+ LOW: "low",
314
+ });
315
+
316
+ export const FRAMEWORKS_V2 = Object.freeze([
317
+ "gdpr",
318
+ "soc2",
319
+ "hipaa",
320
+ "iso27001",
321
+ ]);
322
+ export const POLICY_TYPES_V2 = Object.freeze([
323
+ "retention",
324
+ "access_control",
325
+ "encryption",
326
+ "data_classification",
327
+ "audit_trail",
328
+ ]);
329
+
330
+ export const COMPLIANCE_DEFAULT_MAX_ACTIVE_POLICIES = 20;
331
+ export const COMPLIANCE_DEFAULT_EVIDENCE_RETENTION_MS =
332
+ 180 * 24 * 60 * 60 * 1000; // 180 days
333
+ export const COMPLIANCE_DEFAULT_REPORT_RETENTION_MS = 365 * 24 * 60 * 60 * 1000; // 365 days
334
+
335
+ let _maxActivePolicies = COMPLIANCE_DEFAULT_MAX_ACTIVE_POLICIES;
336
+ let _evidenceRetentionMs = COMPLIANCE_DEFAULT_EVIDENCE_RETENTION_MS;
337
+ let _reportRetentionMs = COMPLIANCE_DEFAULT_REPORT_RETENTION_MS;
338
+
339
+ const _evidenceStatesV2 = new Map();
340
+ const _policyStatesV2 = new Map();
341
+ const _reportStatesV2 = new Map();
342
+
343
+ const EVIDENCE_TRANSITIONS_V2 = new Map([
344
+ ["collected", new Set(["verified", "rejected", "expired"])],
345
+ ["verified", new Set(["expired"])],
346
+ ["rejected", new Set(["expired"])],
347
+ ]);
348
+ const EVIDENCE_TERMINALS_V2 = new Set(["expired"]);
349
+
350
+ const POLICY_TRANSITIONS_V2 = new Map([
351
+ ["draft", new Set(["active", "deprecated"])],
352
+ ["active", new Set(["suspended", "deprecated"])],
353
+ ["suspended", new Set(["active", "deprecated"])],
354
+ ]);
355
+ const POLICY_TERMINALS_V2 = new Set(["deprecated"]);
356
+
357
+ const REPORT_TRANSITIONS_V2 = new Map([
358
+ ["pending", new Set(["generating", "archived"])],
359
+ ["generating", new Set(["published", "archived"])],
360
+ ["published", new Set(["archived"])],
361
+ ]);
362
+ const REPORT_TERMINALS_V2 = new Set(["archived"]);
363
+
364
+ function _positiveInt(n, label) {
365
+ const v = Number(n);
366
+ if (!Number.isFinite(v) || v <= 0) {
367
+ throw new Error(`${label} must be a positive integer`);
368
+ }
369
+ return Math.floor(v);
370
+ }
371
+
372
+ export function setMaxActivePolicies(n) {
373
+ _maxActivePolicies = _positiveInt(n, "maxActivePolicies");
374
+ return _maxActivePolicies;
375
+ }
376
+
377
+ export function setEvidenceRetentionMs(ms) {
378
+ _evidenceRetentionMs = _positiveInt(ms, "evidenceRetentionMs");
379
+ return _evidenceRetentionMs;
380
+ }
381
+
382
+ export function setReportRetentionMs(ms) {
383
+ _reportRetentionMs = _positiveInt(ms, "reportRetentionMs");
384
+ return _reportRetentionMs;
385
+ }
386
+
387
+ export function getMaxActivePolicies() {
388
+ return _maxActivePolicies;
389
+ }
390
+
391
+ export function getEvidenceRetentionMs() {
392
+ return _evidenceRetentionMs;
393
+ }
394
+
395
+ export function getReportRetentionMs() {
396
+ return _reportRetentionMs;
397
+ }
398
+
399
+ export function getActivePolicyCount(framework) {
400
+ let count = 0;
401
+ for (const entry of _policyStatesV2.values()) {
402
+ if (entry.status === POLICY_STATUS_V2.ACTIVE) {
403
+ if (!framework || entry.framework === framework) count += 1;
404
+ }
405
+ }
406
+ return count;
407
+ }
408
+
409
+ /* ── Evidence V2 ────────────────────────────────────────────── */
410
+
411
+ export function registerEvidenceV2(
412
+ db,
413
+ { evidenceId, framework, type, description, source, metadata } = {},
414
+ ) {
415
+ if (!evidenceId) throw new Error("evidenceId is required");
416
+ if (!framework) throw new Error("framework is required");
417
+ if (!FRAMEWORKS_V2.includes(framework)) {
418
+ throw new Error(
419
+ `Invalid framework: ${framework}. Valid: ${FRAMEWORKS_V2.join(", ")}`,
420
+ );
421
+ }
422
+ if (_evidenceStatesV2.has(evidenceId)) {
423
+ throw new Error(`Evidence already registered: ${evidenceId}`);
424
+ }
425
+ const now = Date.now();
426
+ const entry = {
427
+ evidenceId,
428
+ framework,
429
+ type: type || "general",
430
+ description: description || "",
431
+ source: source || "cli",
432
+ status: EVIDENCE_STATUS_V2.COLLECTED,
433
+ metadata: metadata || {},
434
+ reason: null,
435
+ createdAt: now,
436
+ updatedAt: now,
437
+ };
438
+ _evidenceStatesV2.set(evidenceId, entry);
439
+ return { ...entry };
440
+ }
441
+
442
+ export function getEvidenceStatusV2(evidenceId) {
443
+ const entry = _evidenceStatesV2.get(evidenceId);
444
+ return entry ? { ...entry } : null;
445
+ }
446
+
447
+ export function setEvidenceStatusV2(db, evidenceId, newStatus, patch = {}) {
448
+ const entry = _evidenceStatesV2.get(evidenceId);
449
+ if (!entry) throw new Error(`Evidence not found: ${evidenceId}`);
450
+ if (!Object.values(EVIDENCE_STATUS_V2).includes(newStatus)) {
451
+ throw new Error(`Invalid evidence status: ${newStatus}`);
452
+ }
453
+ if (EVIDENCE_TERMINALS_V2.has(entry.status)) {
454
+ throw new Error(`Evidence is terminal: ${entry.status}`);
455
+ }
456
+ const allowed = EVIDENCE_TRANSITIONS_V2.get(entry.status) || new Set();
457
+ if (!allowed.has(newStatus)) {
458
+ throw new Error(`Invalid transition: ${entry.status} → ${newStatus}`);
459
+ }
460
+ entry.status = newStatus;
461
+ entry.updatedAt = Date.now();
462
+ if (patch.reason !== undefined) entry.reason = patch.reason;
463
+ if (patch.metadata) entry.metadata = { ...entry.metadata, ...patch.metadata };
464
+ return { ...entry };
465
+ }
466
+
467
+ export function autoExpireEvidence(db, nowMs = Date.now()) {
468
+ const expired = [];
469
+ for (const entry of _evidenceStatesV2.values()) {
470
+ if (EVIDENCE_TERMINALS_V2.has(entry.status)) continue;
471
+ if (nowMs - entry.createdAt > _evidenceRetentionMs) {
472
+ entry.status = EVIDENCE_STATUS_V2.EXPIRED;
473
+ entry.updatedAt = nowMs;
474
+ entry.reason = "auto-expired: retention exceeded";
475
+ expired.push({ ...entry });
476
+ }
477
+ }
478
+ return expired;
479
+ }
480
+
481
+ /* ── Policy V2 ──────────────────────────────────────────────── */
482
+
483
+ export function registerPolicyV2(
484
+ db,
485
+ { policyId, name, type, framework, severity, rules, metadata } = {},
486
+ ) {
487
+ if (!policyId) throw new Error("policyId is required");
488
+ if (!name) throw new Error("name is required");
489
+ if (!POLICY_TYPES_V2.includes(type)) {
490
+ throw new Error(
491
+ `Invalid policy type: ${type}. Valid: ${POLICY_TYPES_V2.join(", ")}`,
492
+ );
493
+ }
494
+ if (!FRAMEWORKS_V2.includes(framework)) {
495
+ throw new Error(
496
+ `Invalid framework: ${framework}. Valid: ${FRAMEWORKS_V2.join(", ")}`,
497
+ );
498
+ }
499
+ const sev = severity || SEVERITY_V2.MEDIUM;
500
+ if (!Object.values(SEVERITY_V2).includes(sev)) {
501
+ throw new Error(`Invalid severity: ${sev}`);
502
+ }
503
+ if (_policyStatesV2.has(policyId)) {
504
+ throw new Error(`Policy already registered: ${policyId}`);
505
+ }
506
+ const now = Date.now();
507
+ const entry = {
508
+ policyId,
509
+ name,
510
+ type,
511
+ framework,
512
+ severity: sev,
513
+ rules: rules || {},
514
+ status: POLICY_STATUS_V2.DRAFT,
515
+ metadata: metadata || {},
516
+ reason: null,
517
+ createdAt: now,
518
+ updatedAt: now,
519
+ };
520
+ _policyStatesV2.set(policyId, entry);
521
+ return { ...entry };
522
+ }
523
+
524
+ export function getPolicyStatusV2(policyId) {
525
+ const entry = _policyStatesV2.get(policyId);
526
+ return entry ? { ...entry } : null;
527
+ }
528
+
529
+ export function setPolicyStatusV2(db, policyId, newStatus, patch = {}) {
530
+ const entry = _policyStatesV2.get(policyId);
531
+ if (!entry) throw new Error(`Policy not found: ${policyId}`);
532
+ if (!Object.values(POLICY_STATUS_V2).includes(newStatus)) {
533
+ throw new Error(`Invalid policy status: ${newStatus}`);
534
+ }
535
+ if (POLICY_TERMINALS_V2.has(entry.status)) {
536
+ throw new Error(`Policy is terminal: ${entry.status}`);
537
+ }
538
+ const allowed = POLICY_TRANSITIONS_V2.get(entry.status) || new Set();
539
+ if (!allowed.has(newStatus)) {
540
+ throw new Error(`Invalid transition: ${entry.status} → ${newStatus}`);
541
+ }
542
+ if (newStatus === POLICY_STATUS_V2.ACTIVE) {
543
+ const activeCount = getActivePolicyCount(entry.framework);
544
+ if (
545
+ entry.status !== POLICY_STATUS_V2.ACTIVE &&
546
+ activeCount >= _maxActivePolicies
547
+ ) {
548
+ throw new Error(
549
+ `Max active policies reached (${activeCount}/${_maxActivePolicies}) for framework ${entry.framework}`,
550
+ );
551
+ }
552
+ }
553
+ entry.status = newStatus;
554
+ entry.updatedAt = Date.now();
555
+ if (patch.reason !== undefined) entry.reason = patch.reason;
556
+ if (patch.metadata) entry.metadata = { ...entry.metadata, ...patch.metadata };
557
+ return { ...entry };
558
+ }
559
+
560
+ export function activatePolicy(db, policyId) {
561
+ return setPolicyStatusV2(db, policyId, POLICY_STATUS_V2.ACTIVE);
562
+ }
563
+
564
+ /* ── Report V2 ──────────────────────────────────────────────── */
565
+
566
+ export function registerReportV2(
567
+ db,
568
+ { reportId, framework, title, metadata } = {},
569
+ ) {
570
+ if (!reportId) throw new Error("reportId is required");
571
+ if (!framework) throw new Error("framework is required");
572
+ if (!FRAMEWORKS_V2.includes(framework)) {
573
+ throw new Error(`Invalid framework: ${framework}`);
574
+ }
575
+ if (_reportStatesV2.has(reportId)) {
576
+ throw new Error(`Report already registered: ${reportId}`);
577
+ }
578
+ const now = Date.now();
579
+ const entry = {
580
+ reportId,
581
+ framework,
582
+ title: title || `${framework.toUpperCase()} Compliance Report`,
583
+ status: REPORT_STATUS_V2.PENDING,
584
+ score: 0,
585
+ summary: "",
586
+ metadata: metadata || {},
587
+ reason: null,
588
+ createdAt: now,
589
+ updatedAt: now,
590
+ publishedAt: null,
591
+ };
592
+ _reportStatesV2.set(reportId, entry);
593
+ return { ...entry };
594
+ }
595
+
596
+ export function getReportStatusV2(reportId) {
597
+ const entry = _reportStatesV2.get(reportId);
598
+ return entry ? { ...entry } : null;
599
+ }
600
+
601
+ export function setReportStatusV2(db, reportId, newStatus, patch = {}) {
602
+ const entry = _reportStatesV2.get(reportId);
603
+ if (!entry) throw new Error(`Report not found: ${reportId}`);
604
+ if (!Object.values(REPORT_STATUS_V2).includes(newStatus)) {
605
+ throw new Error(`Invalid report status: ${newStatus}`);
606
+ }
607
+ if (REPORT_TERMINALS_V2.has(entry.status)) {
608
+ throw new Error(`Report is terminal: ${entry.status}`);
609
+ }
610
+ const allowed = REPORT_TRANSITIONS_V2.get(entry.status) || new Set();
611
+ if (!allowed.has(newStatus)) {
612
+ throw new Error(`Invalid transition: ${entry.status} → ${newStatus}`);
613
+ }
614
+ entry.status = newStatus;
615
+ entry.updatedAt = Date.now();
616
+ if (newStatus === REPORT_STATUS_V2.PUBLISHED) {
617
+ entry.publishedAt = entry.updatedAt;
618
+ if (typeof patch.score === "number") entry.score = patch.score;
619
+ if (typeof patch.summary === "string") entry.summary = patch.summary;
620
+ }
621
+ if (patch.reason !== undefined) entry.reason = patch.reason;
622
+ if (patch.metadata) entry.metadata = { ...entry.metadata, ...patch.metadata };
623
+ return { ...entry };
624
+ }
625
+
626
+ export function publishReport(db, reportId, { score, summary } = {}) {
627
+ const entry = _reportStatesV2.get(reportId);
628
+ if (!entry) throw new Error(`Report not found: ${reportId}`);
629
+ if (entry.status === REPORT_STATUS_V2.PENDING) {
630
+ setReportStatusV2(db, reportId, REPORT_STATUS_V2.GENERATING);
631
+ }
632
+ return setReportStatusV2(db, reportId, REPORT_STATUS_V2.PUBLISHED, {
633
+ score,
634
+ summary,
635
+ });
636
+ }
637
+
638
+ export function autoArchiveStaleReports(db, nowMs = Date.now()) {
639
+ const archived = [];
640
+ for (const entry of _reportStatesV2.values()) {
641
+ if (entry.status !== REPORT_STATUS_V2.PUBLISHED) continue;
642
+ if (!entry.publishedAt) continue;
643
+ if (nowMs - entry.publishedAt > _reportRetentionMs) {
644
+ entry.status = REPORT_STATUS_V2.ARCHIVED;
645
+ entry.updatedAt = nowMs;
646
+ entry.reason = "auto-archived: retention exceeded";
647
+ archived.push({ ...entry });
648
+ }
649
+ }
650
+ return archived;
651
+ }
652
+
653
+ /* ── Stats V2 ───────────────────────────────────────────────── */
654
+
655
+ export function getComplianceStatsV2() {
656
+ const evidenceByStatus = {
657
+ collected: 0,
658
+ verified: 0,
659
+ rejected: 0,
660
+ expired: 0,
661
+ };
662
+ const policyByStatus = {
663
+ draft: 0,
664
+ active: 0,
665
+ suspended: 0,
666
+ deprecated: 0,
667
+ };
668
+ const reportByStatus = {
669
+ pending: 0,
670
+ generating: 0,
671
+ published: 0,
672
+ archived: 0,
673
+ };
674
+ const policyBySeverity = {
675
+ critical: 0,
676
+ high: 0,
677
+ medium: 0,
678
+ low: 0,
679
+ };
680
+
681
+ for (const entry of _evidenceStatesV2.values()) {
682
+ if (evidenceByStatus[entry.status] !== undefined)
683
+ evidenceByStatus[entry.status] += 1;
684
+ }
685
+ for (const entry of _policyStatesV2.values()) {
686
+ if (policyByStatus[entry.status] !== undefined)
687
+ policyByStatus[entry.status] += 1;
688
+ if (policyBySeverity[entry.severity] !== undefined)
689
+ policyBySeverity[entry.severity] += 1;
690
+ }
691
+ for (const entry of _reportStatesV2.values()) {
692
+ if (reportByStatus[entry.status] !== undefined)
693
+ reportByStatus[entry.status] += 1;
694
+ }
695
+
696
+ return {
697
+ totalEvidence: _evidenceStatesV2.size,
698
+ totalPolicies: _policyStatesV2.size,
699
+ activePolicies: policyByStatus.active,
700
+ totalReports: _reportStatesV2.size,
701
+ publishedReports: reportByStatus.published,
702
+ maxActivePolicies: _maxActivePolicies,
703
+ evidenceRetentionMs: _evidenceRetentionMs,
704
+ reportRetentionMs: _reportRetentionMs,
705
+ evidenceByStatus,
706
+ policyByStatus,
707
+ reportByStatus,
708
+ policyBySeverity,
709
+ };
710
+ }
711
+
284
712
  /* ── Reset (for testing) ───────────────────────────────────── */
285
713
 
286
714
  export function _resetState() {
287
715
  _evidence.clear();
288
716
  _reports.clear();
289
717
  _policies.clear();
718
+ _evidenceStatesV2.clear();
719
+ _policyStatesV2.clear();
720
+ _reportStatesV2.clear();
721
+ _maxActivePolicies = COMPLIANCE_DEFAULT_MAX_ACTIVE_POLICIES;
722
+ _evidenceRetentionMs = COMPLIANCE_DEFAULT_EVIDENCE_RETENTION_MS;
723
+ _reportRetentionMs = COMPLIANCE_DEFAULT_REPORT_RETENTION_MS;
290
724
  }