@mneme-ai/core 2.80.0 → 2.82.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 (78) hide show
  1. package/dist/agent_manifest.d.ts.map +1 -1
  2. package/dist/agent_manifest.js +8 -0
  3. package/dist/agent_manifest.js.map +1 -1
  4. package/dist/bgp_router/bgp_router.test.d.ts +2 -0
  5. package/dist/bgp_router/bgp_router.test.d.ts.map +1 -0
  6. package/dist/bgp_router/bgp_router.test.js +65 -0
  7. package/dist/bgp_router/bgp_router.test.js.map +1 -0
  8. package/dist/bgp_router/index.d.ts +59 -0
  9. package/dist/bgp_router/index.d.ts.map +1 -0
  10. package/dist/bgp_router/index.js +77 -0
  11. package/dist/bgp_router/index.js.map +1 -0
  12. package/dist/byob/byob.test.d.ts +2 -0
  13. package/dist/byob/byob.test.d.ts.map +1 -0
  14. package/dist/byob/byob.test.js +57 -0
  15. package/dist/byob/byob.test.js.map +1 -0
  16. package/dist/byob/index.d.ts +52 -0
  17. package/dist/byob/index.d.ts.map +1 -0
  18. package/dist/byob/index.js +82 -0
  19. package/dist/byob/index.js.map +1 -0
  20. package/dist/edge_mesh/edge_mesh.test.d.ts +2 -0
  21. package/dist/edge_mesh/edge_mesh.test.d.ts.map +1 -0
  22. package/dist/edge_mesh/edge_mesh.test.js +45 -0
  23. package/dist/edge_mesh/edge_mesh.test.js.map +1 -0
  24. package/dist/edge_mesh/index.d.ts +51 -0
  25. package/dist/edge_mesh/index.d.ts.map +1 -0
  26. package/dist/edge_mesh/index.js +59 -0
  27. package/dist/edge_mesh/index.js.map +1 -0
  28. package/dist/honesty_score/honesty_score.test.d.ts +14 -0
  29. package/dist/honesty_score/honesty_score.test.d.ts.map +1 -0
  30. package/dist/honesty_score/honesty_score.test.js +130 -0
  31. package/dist/honesty_score/honesty_score.test.js.map +1 -0
  32. package/dist/honesty_score/index.d.ts +93 -0
  33. package/dist/honesty_score/index.d.ts.map +1 -0
  34. package/dist/honesty_score/index.js +118 -0
  35. package/dist/honesty_score/index.js.map +1 -0
  36. package/dist/idle_compound/idle_compound.test.d.ts +2 -0
  37. package/dist/idle_compound/idle_compound.test.d.ts.map +1 -0
  38. package/dist/idle_compound/idle_compound.test.js +56 -0
  39. package/dist/idle_compound/idle_compound.test.js.map +1 -0
  40. package/dist/idle_compound/index.d.ts +50 -0
  41. package/dist/idle_compound/index.d.ts.map +1 -0
  42. package/dist/idle_compound/index.js +85 -0
  43. package/dist/idle_compound/index.js.map +1 -0
  44. package/dist/index.d.ts +8 -0
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +8 -0
  47. package/dist/index.js.map +1 -1
  48. package/dist/mesh_immune/index.d.ts +56 -0
  49. package/dist/mesh_immune/index.d.ts.map +1 -0
  50. package/dist/mesh_immune/index.js +75 -0
  51. package/dist/mesh_immune/index.js.map +1 -0
  52. package/dist/mesh_immune/mesh_immune.test.d.ts +2 -0
  53. package/dist/mesh_immune/mesh_immune.test.d.ts.map +1 -0
  54. package/dist/mesh_immune/mesh_immune.test.js +60 -0
  55. package/dist/mesh_immune/mesh_immune.test.js.map +1 -0
  56. package/dist/truth_cdn/index.d.ts +63 -0
  57. package/dist/truth_cdn/index.d.ts.map +1 -0
  58. package/dist/truth_cdn/index.js +70 -0
  59. package/dist/truth_cdn/index.js.map +1 -0
  60. package/dist/truth_cdn/truth_cdn.test.d.ts +2 -0
  61. package/dist/truth_cdn/truth_cdn.test.d.ts.map +1 -0
  62. package/dist/truth_cdn/truth_cdn.test.js +63 -0
  63. package/dist/truth_cdn/truth_cdn.test.js.map +1 -0
  64. package/dist/truth_gate/claims.d.ts.map +1 -1
  65. package/dist/truth_gate/claims.js +53 -0
  66. package/dist/truth_gate/claims.js.map +1 -1
  67. package/dist/truth_gate/probes.d.ts.map +1 -1
  68. package/dist/truth_gate/probes.js +214 -0
  69. package/dist/truth_gate/probes.js.map +1 -1
  70. package/dist/truth_stake/index.d.ts +72 -0
  71. package/dist/truth_stake/index.d.ts.map +1 -0
  72. package/dist/truth_stake/index.js +85 -0
  73. package/dist/truth_stake/index.js.map +1 -0
  74. package/dist/truth_stake/truth_stake.test.d.ts +2 -0
  75. package/dist/truth_stake/truth_stake.test.d.ts.map +1 -0
  76. package/dist/truth_stake/truth_stake.test.js +64 -0
  77. package/dist/truth_stake/truth_stake.test.js.map +1 -0
  78. package/package.json +1 -1
@@ -0,0 +1,130 @@
1
+ /**
2
+ * v2.81.0 — HONESTY CREDIT SCORE pinned + QUAN tests.
3
+ * H1 Wilson-LB scoring: small sample penalized; perfect-large > perfect-small
4
+ * H2 band boundaries (PLATINUM/GOLD/SILVER/BRONZE/UNTRUSTED/UNMEASURED)
5
+ * H3 issue → verifyHonestyReceipt round trip (offline)
6
+ * H4 tamper / wrong-issuer / expiry rejected
7
+ * H5 shouldTrust band gating + expiry + issuer assertion
8
+ * QUAN:
9
+ * Q1 monotonic: more true (same total) ⇒ score never decreases
10
+ * Q2 score always in [0,100]; total+deterministic over fuzz; never throws
11
+ * Q3 a vendor cannot self-promote by forging the payload (signature catches it)
12
+ */
13
+ import { describe, it, expect } from "vitest";
14
+ import { mkdtempSync } from "node:fs";
15
+ import { tmpdir } from "node:os";
16
+ import { join } from "node:path";
17
+ import { computeHonestyScore, bandFor, issueHonestyReceipt, verifyHonestyReceipt, shouldTrust, compareBands, MIN_SAMPLE, } from "./index.js";
18
+ import { getIssuerKeyPair } from "../notary/index.js";
19
+ const repo = () => mkdtempSync(join(tmpdir(), "mneme-honesty-"));
20
+ describe("v2.81.0 H1 — Wilson-LB scoring (PINNED)", () => {
21
+ it("H1.1 a small perfect sample scores LOWER than a large perfect sample", () => {
22
+ const small = computeHonestyScore({ agent: "a", trueCount: 5, falseCount: 0 });
23
+ const large = computeHonestyScore({ agent: "a", trueCount: 1000, falseCount: 0 });
24
+ expect(small.score).toBeLessThan(large.score);
25
+ expect(large.score).toBeGreaterThan(95);
26
+ });
27
+ it("H1.2 lies drag the score down", () => {
28
+ const honest = computeHonestyScore({ agent: "a", trueCount: 90, falseCount: 10 });
29
+ const liar = computeHonestyScore({ agent: "b", trueCount: 50, falseCount: 50 });
30
+ expect(honest.score).toBeGreaterThan(liar.score);
31
+ });
32
+ it("H1.3 below MIN_SAMPLE decisive ⇒ UNMEASURED", () => {
33
+ const s = computeHonestyScore({ agent: "a", trueCount: MIN_SAMPLE - 1, falseCount: 0 });
34
+ expect(s.band).toBe("UNMEASURED");
35
+ });
36
+ });
37
+ describe("v2.81.0 H2 — band boundaries (PINNED)", () => {
38
+ it("H2.1 maps scores to bands (with enough samples)", () => {
39
+ const n = 1000;
40
+ expect(bandFor(95, n)).toBe("PLATINUM");
41
+ expect(bandFor(80, n)).toBe("GOLD");
42
+ expect(bandFor(65, n)).toBe("SILVER");
43
+ expect(bandFor(45, n)).toBe("BRONZE");
44
+ expect(bandFor(20, n)).toBe("UNTRUSTED");
45
+ expect(bandFor(95, 1)).toBe("UNMEASURED");
46
+ });
47
+ it("H2.2 compareBands orders trust", () => {
48
+ expect(compareBands("PLATINUM", "BRONZE")).toBeGreaterThan(0);
49
+ expect(compareBands("UNTRUSTED", "SILVER")).toBeLessThan(0);
50
+ });
51
+ });
52
+ describe("v2.81.0 H3+H4 — signed receipt round trip + tamper (PINNED)", () => {
53
+ it("H3.1 issue → verify (offline) valid + carries the score", () => {
54
+ const r = repo();
55
+ const score = computeHonestyScore({ agent: "claude", trueCount: 200, falseCount: 5 });
56
+ const receipt = issueHonestyReceipt(r, score);
57
+ const v = verifyHonestyReceipt(JSON.parse(JSON.stringify(receipt)));
58
+ expect(v.valid).toBe(true);
59
+ expect(v.expired).toBe(false);
60
+ expect(v.score.agent).toBe("claude");
61
+ expect(v.score.band).toBe(score.band);
62
+ });
63
+ it("H4.1 tampering the score fails the signature", () => {
64
+ const r = repo();
65
+ const receipt = issueHonestyReceipt(r, computeHonestyScore({ agent: "a", trueCount: 10, falseCount: 10 }));
66
+ const forged = { ...receipt, payload: { ...receipt.payload, score: 100, band: "PLATINUM" } };
67
+ expect(verifyHonestyReceipt(forged).valid).toBe(false);
68
+ });
69
+ it("H4.2 expired score: valid signature but flagged expired", () => {
70
+ const r = repo();
71
+ const score = computeHonestyScore({ agent: "a", trueCount: 100, falseCount: 1 }, 1000);
72
+ const receipt = issueHonestyReceipt(r, score, { ttlDays: 1 });
73
+ const later = 1000 + 2 * 24 * 60 * 60 * 1000;
74
+ const v = verifyHonestyReceipt(receipt, { now: later });
75
+ expect(v.valid).toBe(true);
76
+ expect(v.expired).toBe(true);
77
+ });
78
+ });
79
+ describe("v2.81.0 H5 — shouldTrust (PINNED)", () => {
80
+ it("H5.1 gates on band, expiry, and issuer", () => {
81
+ const r = repo();
82
+ const high = issueHonestyReceipt(r, computeHonestyScore({ agent: "good", trueCount: 500, falseCount: 2 }));
83
+ const low = issueHonestyReceipt(r, computeHonestyScore({ agent: "bad", trueCount: 30, falseCount: 70 }));
84
+ expect(shouldTrust(high, "GOLD").trust).toBe(true);
85
+ expect(shouldTrust(low, "GOLD").trust).toBe(false);
86
+ // issuer assertion
87
+ const fp = getIssuerKeyPair(r).fingerprint;
88
+ expect(shouldTrust(high, "SILVER", { expectedIssuerFingerprint: fp }).trust).toBe(true);
89
+ expect(shouldTrust(high, "SILVER", { expectedIssuerFingerprint: "deadbeefdeadbeef" }).trust).toBe(false);
90
+ // expiry
91
+ const old = issueHonestyReceipt(r, computeHonestyScore({ agent: "x", trueCount: 500, falseCount: 1 }, 1000), { ttlDays: 1 });
92
+ expect(shouldTrust(old, "BRONZE", { now: 1000 + 5 * 86400000 }).trust).toBe(false);
93
+ });
94
+ });
95
+ // ─────────────────────────── QUAN (property/fuzz) ───────────────────────────
96
+ describe("v2.81.0 Q — honesty score invariants (QUAN)", () => {
97
+ it("Q1 monotonic: adding TRUE claims (same total via swapping a false→true) never lowers the score", () => {
98
+ const total = 60;
99
+ let prev = -1;
100
+ for (let t = 0; t <= total; t++) {
101
+ const s = computeHonestyScore({ agent: "a", trueCount: t, falseCount: total - t });
102
+ expect(s.score).toBeGreaterThanOrEqual(prev);
103
+ prev = s.score;
104
+ }
105
+ });
106
+ it("Q2 score ∈ [0,100], total + deterministic over fuzz, never throws", () => {
107
+ for (let i = 0; i < 300; i++) {
108
+ const t = (i * 7) % 250;
109
+ const f = (i * 13) % 130;
110
+ const p = (i * 5) % 40;
111
+ const s1 = computeHonestyScore({ agent: `a${i}`, trueCount: t, falseCount: f, partialCount: p });
112
+ const s2 = computeHonestyScore({ agent: `a${i}`, trueCount: t, falseCount: f, partialCount: p }, s1.computedAt);
113
+ expect(s1.score).toBeGreaterThanOrEqual(0);
114
+ expect(s1.score).toBeLessThanOrEqual(100);
115
+ expect(["PLATINUM", "GOLD", "SILVER", "BRONZE", "UNTRUSTED", "UNMEASURED"]).toContain(s1.band);
116
+ expect(s2.score).toBe(s1.score);
117
+ }
118
+ // garbage inputs never throw
119
+ expect(() => computeHonestyScore({ agent: "x", trueCount: -5, falseCount: NaN })).not.toThrow();
120
+ });
121
+ it("Q3 a vendor cannot self-promote: forging band/score in the payload breaks verify", () => {
122
+ const r = repo();
123
+ for (let i = 0; i < 20; i++) {
124
+ const receipt = issueHonestyReceipt(r, computeHonestyScore({ agent: `v${i}`, trueCount: i, falseCount: 50 - i }));
125
+ const forged = { ...receipt, payload: { ...receipt.payload, score: 99, band: "PLATINUM" } };
126
+ expect(verifyHonestyReceipt(forged).valid, `forge ${i} must fail`).toBe(false);
127
+ }
128
+ });
129
+ });
130
+ //# sourceMappingURL=honesty_score.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"honesty_score.test.js","sourceRoot":"","sources":["../../src/honesty_score/honesty_score.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;A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,UAAU,EAAE,EAAmB,CAAC;YACzH,MAAM,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACjF,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * v2.81.0 — HONESTY CREDIT SCORE · portable, signed "credit bureau for AI honesty"
3
+ * (TRUST FABRIC diamond 💎5, built on the v2.79 NOTARY spine).
4
+ *
5
+ * ERC-8004 gives on-chain reputation for "did the agent finish the job / pay?" —
6
+ * nobody measures "does the agent tell the TRUTH?" in a PORTABLE way. That axis
7
+ * is the one connectivity standards never touch, and the one Mneme is built for:
8
+ * BOUNTY/OBELISK already measure a vendor's falseRate from REAL verified claims.
9
+ *
10
+ * 💎5 turns that measurement into a PORTABLE, SIGNED, OFFLINE-VERIFIABLE artifact:
11
+ * a Wilson-lower-bound honesty score wrapped in a NOTARY receipt. Agent A, before
12
+ * delegating to agent B (over A2A / x402 / anything), fetches B's signed honesty
13
+ * receipt and verifies it OFFLINE — no Mneme, no network — then decides whether to
14
+ * trust B. A vendor CANNOT self-certify: the score comes from adversarially-
15
+ * verified claims and is signed by the measuring issuer's key.
16
+ *
17
+ * Wilson LOWER bound (reused from bench/) is deliberate: small samples can't fake a
18
+ * high score — an unproven agent scores low until it has a track record.
19
+ *
20
+ * Pure except issue/verify (sign / read key). Defensive; never throws on verify.
21
+ */
22
+ import { type NotaryReceipt, type IssuerKeyPair } from "../notary/index.js";
23
+ export type HonestyBand = "PLATINUM" | "GOLD" | "SILVER" | "BRONZE" | "UNTRUSTED" | "UNMEASURED";
24
+ /** Minimum decisive (true+false) claims before a score is considered measured. */
25
+ export declare const MIN_SAMPLE = 5;
26
+ /** Default validity window — an honesty score is a snapshot, not forever. */
27
+ export declare const DEFAULT_TTL_DAYS = 90;
28
+ export interface HonestyInputs {
29
+ agent: string;
30
+ /** Claims independently verified TRUE. */
31
+ trueCount: number;
32
+ /** Claims independently verified FALSE. */
33
+ falseCount: number;
34
+ /** Claims partially true (counted as half-weight true). */
35
+ partialCount?: number;
36
+ }
37
+ export interface HonestyScore {
38
+ agent: string;
39
+ /** 0-100, = Wilson-LB(true-rate) × 100 (pessimistic on small samples). */
40
+ score: number;
41
+ band: HonestyBand;
42
+ trueCount: number;
43
+ falseCount: number;
44
+ partialCount: number;
45
+ /** true + false (+ partial) decisive claims. */
46
+ decisive: number;
47
+ /** Raw Wilson lower bound 0..1. */
48
+ wilsonLB: number;
49
+ computedAt: number;
50
+ }
51
+ /** Band from a measured score; UNMEASURED when below the sample floor. */
52
+ export declare function bandFor(score: number, decisive: number): HonestyBand;
53
+ /**
54
+ * Compute a portable honesty score. Wilson 95% LOWER bound on the true-rate,
55
+ * partial claims weighted 0.5. Small/under-measured agents score low by design.
56
+ */
57
+ export declare function computeHonestyScore(inputs: HonestyInputs, now?: number): HonestyScore;
58
+ export interface HonestyReceiptPayload extends HonestyScore {
59
+ v: 1;
60
+ expiresAt: number;
61
+ }
62
+ /** Wrap a score in a signed, portable NOTARY receipt (offline-verifiable). */
63
+ export declare function issueHonestyReceipt(repoRoot: string, score: HonestyScore, opts?: {
64
+ ttlDays?: number;
65
+ keyPair?: IssuerKeyPair;
66
+ }): NotaryReceipt;
67
+ export interface HonestyVerifyResult {
68
+ valid: boolean;
69
+ reason: string;
70
+ expired?: boolean;
71
+ score?: HonestyReceiptPayload;
72
+ issuerFingerprint?: string;
73
+ }
74
+ /** Verify an honesty receipt OFFLINE: signature + payload shape + expiry. */
75
+ export declare function verifyHonestyReceipt(receipt: unknown, opts?: {
76
+ now?: number;
77
+ }): HonestyVerifyResult;
78
+ /**
79
+ * Decision helper: should I trust this agent at >= minBand? Verifies the receipt
80
+ * offline, rejects expired scores, and compares the band. The "check before you
81
+ * delegate" call an agent makes before handing work/payment to another agent.
82
+ */
83
+ export declare function shouldTrust(receipt: unknown, minBand?: HonestyBand, opts?: {
84
+ now?: number;
85
+ expectedIssuerFingerprint?: string;
86
+ }): {
87
+ trust: boolean;
88
+ reason: string;
89
+ band?: HonestyBand;
90
+ };
91
+ /** Compare two bands: >0 if a is more trustworthy than b. */
92
+ export declare function compareBands(a: HonestyBand, b: HonestyBand): number;
93
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/honesty_score/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAA+B,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEzG,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,GAAG,YAAY,CAAC;AAEjG,kFAAkF;AAClF,eAAO,MAAM,UAAU,IAAI,CAAC;AAC5B,6EAA6E;AAC7E,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAInC,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,0EAA0E;IAC1E,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,gDAAgD;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAMD,0EAA0E;AAC1E,wBAAgB,OAAO,CAAC,KAAK,EA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/**
2
+ * v2.81.0 — HONESTY CREDIT SCORE · portable, signed "credit bureau for AI honesty"
3
+ * (TRUST FABRIC diamond 💎5, built on the v2.79 NOTARY spine).
4
+ *
5
+ * ERC-8004 gives on-chain reputation for "did the agent finish the job / pay?" —
6
+ * nobody measures "does the agent tell the TRUTH?" in a PORTABLE way. That axis
7
+ * is the one connectivity standards never touch, and the one Mneme is built for:
8
+ * BOUNTY/OBELISK already measure a vendor's falseRate from REAL verified claims.
9
+ *
10
+ * 💎5 turns that measurement into a PORTABLE, SIGNED, OFFLINE-VERIFIABLE artifact:
11
+ * a Wilson-lower-bound honesty score wrapped in a NOTARY receipt. Agent A, before
12
+ * delegating to agent B (over A2A / x402 / anything), fetches B's signed honesty
13
+ * receipt and verifies it OFFLINE — no Mneme, no network — then decides whether to
14
+ * trust B. A vendor CANNOT self-certify: the score comes from adversarially-
15
+ * verified claims and is signed by the measuring issuer's key.
16
+ *
17
+ * Wilson LOWER bound (reused from bench/) is deliberate: small samples can't fake a
18
+ * high score — an unproven agent scores low until it has a track record.
19
+ *
20
+ * Pure except issue/verify (sign / read key). Defensive; never throws on verify.
21
+ */
22
+ import { wilsonLowerBound } from "../bench/bench.js";
23
+ import { issueReceipt, verifyReceipt } from "../notary/index.js";
24
+ /** Minimum decisive (true+false) claims before a score is considered measured. */
25
+ export const MIN_SAMPLE = 5;
26
+ /** Default validity window — an honesty score is a snapshot, not forever. */
27
+ export const DEFAULT_TTL_DAYS = 90;
28
+ const BAND_ORDER = ["UNTRUSTED", "BRONZE", "SILVER", "GOLD", "PLATINUM"];
29
+ function clampInt(n) {
30
+ return typeof n === "number" && Number.isFinite(n) && n >= 0 ? Math.floor(n) : 0;
31
+ }
32
+ /** Band from a measured score; UNMEASURED when below the sample floor. */
33
+ export function bandFor(score, decisive) {
34
+ if (decisive < MIN_SAMPLE)
35
+ return "UNMEASURED";
36
+ if (score >= 90)
37
+ return "PLATINUM";
38
+ if (score >= 75)
39
+ return "GOLD";
40
+ if (score >= 60)
41
+ return "SILVER";
42
+ if (score >= 40)
43
+ return "BRONZE";
44
+ return "UNTRUSTED";
45
+ }
46
+ /**
47
+ * Compute a portable honesty score. Wilson 95% LOWER bound on the true-rate,
48
+ * partial claims weighted 0.5. Small/under-measured agents score low by design.
49
+ */
50
+ export function computeHonestyScore(inputs, now = Date.now()) {
51
+ const trueCount = clampInt(inputs.trueCount);
52
+ const falseCount = clampInt(inputs.falseCount);
53
+ const partialCount = clampInt(inputs.partialCount);
54
+ const decisive = trueCount + falseCount + partialCount;
55
+ const positive = trueCount + 0.5 * partialCount;
56
+ const wilsonLB = decisive === 0 ? 0 : wilsonLowerBound(positive, decisive);
57
+ const score = Math.round(wilsonLB * 100);
58
+ return {
59
+ agent: String(inputs.agent ?? "unknown"),
60
+ score,
61
+ band: bandFor(score, decisive),
62
+ trueCount, falseCount, partialCount, decisive,
63
+ wilsonLB,
64
+ computedAt: now,
65
+ };
66
+ }
67
+ /** Wrap a score in a signed, portable NOTARY receipt (offline-verifiable). */
68
+ export function issueHonestyReceipt(repoRoot, score, opts = {}) {
69
+ const ttlDays = opts.ttlDays ?? DEFAULT_TTL_DAYS;
70
+ const payload = {
71
+ v: 1,
72
+ ...score,
73
+ expiresAt: score.computedAt + ttlDays * 24 * 60 * 60 * 1000,
74
+ };
75
+ return issueReceipt(repoRoot, {
76
+ kind: "claim-verdict",
77
+ subject: `honesty:${score.agent}`,
78
+ payload,
79
+ }, opts.keyPair);
80
+ }
81
+ /** Verify an honesty receipt OFFLINE: signature + payload shape + expiry. */
82
+ export function verifyHonestyReceipt(receipt, opts = {}) {
83
+ const v = verifyReceipt(receipt);
84
+ if (!v.valid)
85
+ return { valid: false, reason: v.reason };
86
+ const payload = receipt.payload;
87
+ if (!payload || typeof payload.score !== "number" || typeof payload.expiresAt !== "number" || typeof payload.agent !== "string") {
88
+ return { valid: false, reason: "receipt payload is not an honesty score" };
89
+ }
90
+ const now = opts.now ?? Date.now();
91
+ const expired = now > payload.expiresAt;
92
+ return { valid: true, reason: expired ? "valid signature but score expired" : "ok", expired, score: payload, issuerFingerprint: v.issuerFingerprint };
93
+ }
94
+ /**
95
+ * Decision helper: should I trust this agent at >= minBand? Verifies the receipt
96
+ * offline, rejects expired scores, and compares the band. The "check before you
97
+ * delegate" call an agent makes before handing work/payment to another agent.
98
+ */
99
+ export function shouldTrust(receipt, minBand = "SILVER", opts = {}) {
100
+ const v = verifyHonestyReceipt(receipt, { now: opts.now });
101
+ if (!v.valid)
102
+ return { trust: false, reason: v.reason };
103
+ if (v.expired)
104
+ return { trust: false, reason: "honesty score has expired — request a fresh one", band: v.score.band };
105
+ if (opts.expectedIssuerFingerprint && opts.expectedIssuerFingerprint !== v.issuerFingerprint) {
106
+ return { trust: false, reason: "score signed by an unexpected issuer", band: v.score.band };
107
+ }
108
+ const band = v.score.band;
109
+ if (band === "UNMEASURED")
110
+ return { trust: false, reason: "agent is unmeasured (too few verified claims)", band };
111
+ const ok = BAND_ORDER.indexOf(band) >= BAND_ORDER.indexOf(minBand);
112
+ return { trust: ok, reason: ok ? `band ${band} ≥ required ${minBand}` : `band ${band} < required ${minBand}`, band };
113
+ }
114
+ /** Compare two bands: >0 if a is more trustworthy than b. */
115
+ export function compareBands(a, b) {
116
+ return BAND_ORDER.indexOf(a) - BAND_ORDER.indexOf(b);
117
+ }
118
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/honesty_score/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,aAAa,EAA0C,MAAM,oBAAoB,CAAC;AAIzG,kFAAkF;AAClF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC;AAC5B,6EAA6E;AAC7E,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAEnC,MAAM,UAAU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IACD,MAAM,IAAI,GAAG,CAAC,CAAC,KAAM,CAAC,IAAI,CAAC;IAC3B,IAAI,IAAI,KAAK,YAAY;QAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,+CAA+C,EAAE,IAAI,EAAE,CAAC;IAClH,MAAM,EAAE,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACnE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,IAAI,eAAe,OAAO,EAAE,CAAC,CAAC,CAAC,QAAQ,IAAI,eAAe,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC;AACvH,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,YAAY,CAAC,CAAc,EAAE,CAAc;IACzD,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACvD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=idle_compound.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idle_compound.test.d.ts","sourceRoot":"","sources":["../../src/idle_compound/idle_compound.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * v2.82.0 — IDLE-TIME COMPOUNDING pinned + QUAN tests (💎10).
3
+ */
4
+ import { describe, it, expect } from "vitest";
5
+ import { consolidate } from "./index.js";
6
+ describe("v2.82.0 💎10 Idle Compounding (PINNED)", () => {
7
+ it("I1 near-duplicate TRUE claims merge into one higher-support axiom", () => {
8
+ const claims = [
9
+ { id: "1", text: "the auth module uses bcrypt for password hashing", verdict: "TRUE" },
10
+ { id: "2", text: "auth module uses bcrypt password hashing", verdict: "TRUE" },
11
+ { id: "3", text: "the database is postgres", verdict: "TRUE" },
12
+ ];
13
+ const r = consolidate(claims);
14
+ expect(r.axioms.length).toBe(2);
15
+ const bcrypt = r.axioms.find((a) => a.text.includes("bcrypt"));
16
+ expect(bcrypt.support).toBe(2);
17
+ expect(bcrypt.ids).toEqual(["1", "2"]);
18
+ expect(r.compoundedCount).toBe(1); // 3 trues → 2 axioms
19
+ });
20
+ it("I2 FALSE claims that contradict an axiom are pruned as contradictions", () => {
21
+ const claims = [
22
+ { id: "1", text: "the auth module uses bcrypt password hashing", verdict: "TRUE" },
23
+ { id: "2", text: "the auth module uses bcrypt password hashing scheme", verdict: "FALSE" },
24
+ { id: "3", text: "totally unrelated false thing about weather", verdict: "FALSE" },
25
+ ];
26
+ const r = consolidate(claims);
27
+ expect(r.contradictions).toBe(1);
28
+ expect(r.pruned.find((p) => p.id === "2").reason).toMatch(/contradicts/);
29
+ expect(r.pruned.find((p) => p.id === "3").reason).toMatch(/not promoted/);
30
+ });
31
+ it("I3 UNVERIFIED claims are not promoted", () => {
32
+ const r = consolidate([{ id: "1", text: "maybe true thing", verdict: "UNVERIFIED" }]);
33
+ expect(r.axioms.length).toBe(0);
34
+ expect(r.pruned[0].reason).toMatch(/unverified/);
35
+ });
36
+ });
37
+ describe("v2.82.0 💎10 QUAN", () => {
38
+ it("Q deterministic + idempotent fixed point + order-independent", () => {
39
+ const base = [];
40
+ for (let i = 0; i < 40; i++) {
41
+ const topic = i % 5;
42
+ base.push({ id: `c${i}`, text: `topic ${topic} fact alpha beta gamma ${topic}`, verdict: (i % 7 === 0 ? "FALSE" : i % 11 === 0 ? "UNVERIFIED" : "TRUE") });
43
+ }
44
+ const r1 = consolidate(base);
45
+ const r2 = consolidate(base.slice().reverse());
46
+ // order-independent axiom set (compare canonical texts + supports)
47
+ const sig = (r) => r.axioms.map((a) => `${a.text}#${a.support}`).sort();
48
+ expect(sig(r1)).toEqual(sig(r2));
49
+ // idempotent: feeding the axioms back as TRUE claims yields the same axioms
50
+ const asClaims = r1.axioms.map((a, i) => ({ id: `x${i}`, text: a.text, verdict: "TRUE" }));
51
+ const r3 = consolidate(asClaims);
52
+ expect(r3.axioms.length).toBe(r1.axioms.length);
53
+ expect(r1.axioms.every((a) => a.support >= 1)).toBe(true);
54
+ });
55
+ });
56
+ //# sourceMappingURL=idle_compound.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idle_compound.test.js","sourceRoot":"","sources":["../../src/idle_compound/idle_compound.test.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,WAAW,EAA2B,MAAM,YAAY,CAAC;AAElE,QAAQ,CAAC,wCAAwC,EAAE,GAAG,EAAE;IACtD,EAAE,CAAC,mEAAmE,EAAE,GAAG,EAAE;QAC3E,MAAM,MAAM,GAAyB;YACnC,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,kDAAkD,EAAE,OAAO,EAAE,MAAM,EAAE;YACtF,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,0CAA0C,EAAE,OAAO,EAAE,MAAM,EAAE;YAC9E,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,0BAA0B,EAAE,OAAO,EAAE,MAAM,EAAE;SAC/D,CAAC;QACF,MAAM,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;QAC9B,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAChC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAE,CAAC;QAChE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,GA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E,CAAC,CAAC,CAAC;QACjC,4EAA4E;QAC5E,MAAM,QAAQ,GAAyB,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,MAAe,EAAE,CAAC,CAAC,CAAC;QAC1H,MAAM,EAAE,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;QACjC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAChD,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * v2.82.0 — IDLE-TIME COMPOUNDING · the agent that gets smarter while it sleeps
3
+ * (TRUST FABRIC 💎10 — the contrarian "optimize idle, not inference" bet).
4
+ *
5
+ * Everyone optimizes inference (bigger model, longer context). Nobody turns an
6
+ * agent's IDLE time into compounding advantage. IDLE-COMPOUND consolidates the
7
+ * agent's VERIFIED claims into axioms during the gap between sessions: near-duplicate
8
+ * truths merge into one higher-support axiom, contradictions are pruned, and the
9
+ * agent wakes with a smaller, stronger, deduplicated truth base — interest compounding
10
+ * on verified knowledge. (Mneme's dream.run REM-consolidation + osmosis distillation,
11
+ * made deterministic.)
12
+ *
13
+ * Pure + deterministic + idempotent: consolidating an already-consolidated set is a
14
+ * fixed point. Never throws.
15
+ */
16
+ export type Verdict = "TRUE" | "FALSE" | "UNVERIFIED";
17
+ export interface ConsolidationClaim {
18
+ id: string;
19
+ text: string;
20
+ verdict: Verdict;
21
+ ts?: number;
22
+ }
23
+ export interface Axiom {
24
+ /** Canonical text (the longest/most-specific of the merged claims). */
25
+ text: string;
26
+ /** How many verified TRUE claims folded into this axiom. */
27
+ support: number;
28
+ /** The source claim ids. */
29
+ ids: string[];
30
+ }
31
+ export interface ConsolidationResult {
32
+ axioms: Axiom[];
33
+ pruned: Array<{
34
+ id: string;
35
+ reason: string;
36
+ }>;
37
+ /** Raw TRUE claims folded minus resulting axioms = compression won. */
38
+ compoundedCount: number;
39
+ contradictions: number;
40
+ }
41
+ /**
42
+ * Consolidate verified claims into axioms.
43
+ * - TRUE claims with jaccard token overlap ≥ threshold merge into ONE axiom
44
+ * (canonical = longest text; support = members; ids sorted).
45
+ * - A FALSE claim that overlaps a TRUE axiom (≥ threshold) is a CONTRADICTION → pruned.
46
+ * - UNVERIFIED claims are not promoted (pruned: "unverified").
47
+ * Deterministic: claims are processed in id order; idempotent on its own axiom output.
48
+ */
49
+ export declare function consolidate(claims: ConsolidationClaim[], threshold?: number): ConsolidationResult;
50
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/idle_compound/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,YAAY,CAAC;AAEtD,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,KAAK;IACpB,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;IACb,4DAA4D;IAC5D,OAAO,EAAE,MAAM,CAAC;IAChB,4BAA4B;IAC5B,GAAG,EAAE,MAAM,EAAE,CAAC;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,MAAM,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC9C,uEAAuE;IACvE,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;CACxB;AAkBD;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,kBAAkB,EAAE,EAAE,SAAS,SAAM,GAAG,mBAAmB,CA6C9F"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * v2.82.0 — IDLE-TIME COMPOUNDING · the agent that gets smarter while it sleeps
3
+ * (TRUST FABRIC 💎10 — the contrarian "optimize idle, not inference" bet).
4
+ *
5
+ * Everyone optimizes inference (bigger model, longer context). Nobody turns an
6
+ * agent's IDLE time into compounding advantage. IDLE-COMPOUND consolidates the
7
+ * agent's VERIFIED claims into axioms during the gap between sessions: near-duplicate
8
+ * truths merge into one higher-support axiom, contradictions are pruned, and the
9
+ * agent wakes with a smaller, stronger, deduplicated truth base — interest compounding
10
+ * on verified knowledge. (Mneme's dream.run REM-consolidation + osmosis distillation,
11
+ * made deterministic.)
12
+ *
13
+ * Pure + deterministic + idempotent: consolidating an already-consolidated set is a
14
+ * fixed point. Never throws.
15
+ */
16
+ const STOP = new Set(["the", "a", "an", "is", "are", "of", "to", "in", "on", "by", "and", "or", "for", "with", "that", "this", "it", "as", "be", "was", "were", "has", "have"]);
17
+ function tokens(s) {
18
+ return new Set(s.toLowerCase().replace(/[^a-z0-9\s]/g, " ").split(/\s+/).filter((t) => t.length > 1 && !STOP.has(t)));
19
+ }
20
+ function jaccard(a, b) {
21
+ if (a.size === 0 && b.size === 0)
22
+ return 1;
23
+ let inter = 0;
24
+ for (const t of a)
25
+ if (b.has(t))
26
+ inter++;
27
+ const union = a.size + b.size - inter;
28
+ return union === 0 ? 0 : inter / union;
29
+ }
30
+ /**
31
+ * Consolidate verified claims into axioms.
32
+ * - TRUE claims with jaccard token overlap ≥ threshold merge into ONE axiom
33
+ * (canonical = longest text; support = members; ids sorted).
34
+ * - A FALSE claim that overlaps a TRUE axiom (≥ threshold) is a CONTRADICTION → pruned.
35
+ * - UNVERIFIED claims are not promoted (pruned: "unverified").
36
+ * Deterministic: claims are processed in id order; idempotent on its own axiom output.
37
+ */
38
+ export function consolidate(claims, threshold = 0.6) {
39
+ const list = (Array.isArray(claims) ? claims : []).filter((c) => c && typeof c.id === "string" && typeof c.text === "string");
40
+ const sorted = list.slice().sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
41
+ const trues = sorted.filter((c) => c.verdict === "TRUE");
42
+ const falses = sorted.filter((c) => c.verdict === "FALSE");
43
+ const unverified = sorted.filter((c) => c.verdict !== "TRUE" && c.verdict !== "FALSE");
44
+ const clusters = [];
45
+ for (const c of trues) {
46
+ const tk = tokens(c.text);
47
+ let placed = false;
48
+ for (const cl of clusters) {
49
+ if (jaccard(tk, cl.tokensU) >= threshold) {
50
+ cl.members.push(c);
51
+ for (const t of tk)
52
+ cl.tokensU.add(t);
53
+ placed = true;
54
+ break;
55
+ }
56
+ }
57
+ if (!placed)
58
+ clusters.push({ tokensU: new Set(tk), members: [c] });
59
+ }
60
+ const axioms = clusters.map((cl) => {
61
+ const canonical = cl.members.reduce((best, m) => m.text.length > best.length ? m.text : best, "");
62
+ return { text: canonical, support: cl.members.length, ids: cl.members.map((m) => m.id).sort() };
63
+ }).sort((a, b) => b.support - a.support || (a.text < b.text ? -1 : 1));
64
+ const pruned = [];
65
+ let contradictions = 0;
66
+ for (const f of falses) {
67
+ const tk = tokens(f.text);
68
+ const hits = clusters.some((cl) => jaccard(tk, cl.tokensU) >= threshold);
69
+ if (hits) {
70
+ contradictions++;
71
+ pruned.push({ id: f.id, reason: "contradicts a verified axiom" });
72
+ }
73
+ else
74
+ pruned.push({ id: f.id, reason: "verified false (not promoted)" });
75
+ }
76
+ for (const u of unverified)
77
+ pruned.push({ id: u.id, reason: "unverified — not promoted to axiom" });
78
+ return {
79
+ axioms,
80
+ pruned,
81
+ compoundedCount: Math.max(0, trues.length - axioms.length),
82
+ contradictions,
83
+ };
84
+ }
85
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/idle_compound/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA4BH,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;AAEhL,SAAS,MAAM,CAAC,CAAS;IACvB,OAAO,IAAI,GAAG,CACZ,CAAC,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CACtG,CAAC;AACJ,CAAC;AAED,SAAS,OAAO,CAAC,CAAc,EAAE,CAAc;IAC7C,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAC3C,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,CAAC,IAAI,CAAC;QAAE,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAAE,KAAK,EAAE,CAAC;IACzC,MAAM,KAAK,GAAG,CAAC,CAAC,IAAI,GAAG,CA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 @@ export * as notifier from "./notifier/index.js";
229
229
  export * as immune from "./immune/index.js";
230
230
  export * as notary from "./notary/index.js";
231
231
  export * as flightRecorder from "./flight_recorder/index.js";
232
+ export * as honestyScore from "./honesty_score/index.js";
233
+ export * as truthStake from "./truth_stake/index.js";
234
+ export * as meshImmune from "./mesh_immune/index.js";
235
+ export * as bgpRouter from "./bgp_router/index.js";
236
+ export * as byob from "./byob/index.js";
237
+ export * as truthCdn from "./truth_cdn/index.js";
238
+ export * as edgeMesh from "./edge_mesh/index.js";
239
+ export * as idleCompound from "./idle_compound/index.js";
232
240
  export * as agent from "./agent/index.js";
233
241
  export * as selfcheck from "./selfcheck/index.js";
234
242
  export * as integrations from "./integrations/index.js";