@mneme-ai/core 2.29.1 → 2.31.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 (94) hide show
  1. package/dist/agent_manifest.d.ts +1 -1
  2. package/dist/agent_manifest.d.ts.map +1 -1
  3. package/dist/agent_manifest.js +23 -0
  4. package/dist/agent_manifest.js.map +1 -1
  5. package/dist/conclave/aletheia_weights.d.ts.map +1 -1
  6. package/dist/conclave/aletheia_weights.js +16 -4
  7. package/dist/conclave/aletheia_weights.js.map +1 -1
  8. package/dist/diaspora/http_bridge.d.ts.map +1 -1
  9. package/dist/hgp/hgp.test.d.ts +2 -0
  10. package/dist/hgp/hgp.test.d.ts.map +1 -0
  11. package/dist/hgp/hgp.test.js +198 -0
  12. package/dist/hgp/hgp.test.js.map +1 -0
  13. package/dist/hgp/hgp_id.d.ts +18 -0
  14. package/dist/hgp/hgp_id.d.ts.map +1 -0
  15. package/dist/hgp/hgp_id.js +41 -0
  16. package/dist/hgp/hgp_id.js.map +1 -0
  17. package/dist/hgp/index.d.ts +12 -0
  18. package/dist/hgp/index.d.ts.map +1 -0
  19. package/dist/hgp/index.js +10 -0
  20. package/dist/hgp/index.js.map +1 -0
  21. package/dist/hgp/registry.d.ts +64 -0
  22. package/dist/hgp/registry.d.ts.map +1 -0
  23. package/dist/hgp/registry.js +221 -0
  24. package/dist/hgp/registry.js.map +1 -0
  25. package/dist/hgp/severity.d.ts +19 -0
  26. package/dist/hgp/severity.d.ts.map +1 -0
  27. package/dist/hgp/severity.js +46 -0
  28. package/dist/hgp/severity.js.map +1 -0
  29. package/dist/hgp/types.d.ts +60 -0
  30. package/dist/hgp/types.d.ts.map +1 -0
  31. package/dist/hgp/types.js +11 -0
  32. package/dist/hgp/types.js.map +1 -0
  33. package/dist/honest_mirror/anonymizer.d.ts +29 -0
  34. package/dist/honest_mirror/anonymizer.d.ts.map +1 -0
  35. package/dist/honest_mirror/anonymizer.js +77 -0
  36. package/dist/honest_mirror/anonymizer.js.map +1 -0
  37. package/dist/honest_mirror/calibration.d.ts +37 -0
  38. package/dist/honest_mirror/calibration.d.ts.map +1 -0
  39. package/dist/honest_mirror/calibration.js +106 -0
  40. package/dist/honest_mirror/calibration.js.map +1 -0
  41. package/dist/honest_mirror/engine.d.ts +66 -0
  42. package/dist/honest_mirror/engine.d.ts.map +1 -0
  43. package/dist/honest_mirror/engine.js +227 -0
  44. package/dist/honest_mirror/engine.js.map +1 -0
  45. package/dist/honest_mirror/honest_mirror.test.d.ts +2 -0
  46. package/dist/honest_mirror/honest_mirror.test.d.ts.map +1 -0
  47. package/dist/honest_mirror/honest_mirror.test.js +109 -0
  48. package/dist/honest_mirror/honest_mirror.test.js.map +1 -0
  49. package/dist/honest_mirror/index.d.ts +11 -0
  50. package/dist/honest_mirror/index.d.ts.map +1 -0
  51. package/dist/honest_mirror/index.js +9 -0
  52. package/dist/honest_mirror/index.js.map +1 -0
  53. package/dist/honest_mirror/sources/git_commit_source.d.ts +30 -0
  54. package/dist/honest_mirror/sources/git_commit_source.d.ts.map +1 -0
  55. package/dist/honest_mirror/sources/git_commit_source.js +106 -0
  56. package/dist/honest_mirror/sources/git_commit_source.js.map +1 -0
  57. package/dist/honest_mirror/types.d.ts +126 -0
  58. package/dist/honest_mirror/types.d.ts.map +1 -0
  59. package/dist/honest_mirror/types.js +31 -0
  60. package/dist/honest_mirror/types.js.map +1 -0
  61. package/dist/index.d.ts +3 -0
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +22 -0
  64. package/dist/index.js.map +1 -1
  65. package/dist/rewind/engine.d.ts +65 -0
  66. package/dist/rewind/engine.d.ts.map +1 -0
  67. package/dist/rewind/engine.js +473 -0
  68. package/dist/rewind/engine.js.map +1 -0
  69. package/dist/rewind/index.d.ts +13 -0
  70. package/dist/rewind/index.d.ts.map +1 -0
  71. package/dist/rewind/index.js +11 -0
  72. package/dist/rewind/index.js.map +1 -0
  73. package/dist/rewind/intent_class.d.ts +35 -0
  74. package/dist/rewind/intent_class.d.ts.map +1 -0
  75. package/dist/rewind/intent_class.js +141 -0
  76. package/dist/rewind/intent_class.js.map +1 -0
  77. package/dist/rewind/rewind.test.d.ts +2 -0
  78. package/dist/rewind/rewind.test.d.ts.map +1 -0
  79. package/dist/rewind/rewind.test.js +176 -0
  80. package/dist/rewind/rewind.test.js.map +1 -0
  81. package/dist/rewind/types.d.ts +140 -0
  82. package/dist/rewind/types.d.ts.map +1 -0
  83. package/dist/rewind/types.js +11 -0
  84. package/dist/rewind/types.js.map +1 -0
  85. package/dist/squadron/acgv_vaccine.d.ts.map +1 -1
  86. package/dist/squadron/acgv_vaccine.js +15 -0
  87. package/dist/squadron/acgv_vaccine.js.map +1 -1
  88. package/dist/truth_gate/claims.d.ts.map +1 -1
  89. package/dist/truth_gate/claims.js +37 -0
  90. package/dist/truth_gate/claims.js.map +1 -1
  91. package/dist/truth_gate/probes.d.ts.map +1 -1
  92. package/dist/truth_gate/probes.js +107 -1
  93. package/dist/truth_gate/probes.js.map +1 -1
  94. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"severity.d.ts","sourceRoot":"","sources":["../../src/hgp/severity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGtE,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,cAAc,CActG;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,cAAc,EAAE,CAM1F;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,SAAK,GAAG,mBAAmB,EAAE,CAKnG"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * v2.31.0 — HGP severity scoring by vendor + time window.
3
+ *
4
+ * Powers `mneme.hgp.severity --vendor anthropic --window 30d`.
5
+ *
6
+ * Composes with CONCLAVE Aletheia weights: vendors with high HGP
7
+ * severity over the recent window can be auto-downgraded in the
8
+ * vote-weight feedback file (next iteration; v2.31.0 surfaces the
9
+ * signal, v2.32.x wires the auto-downgrade).
10
+ */
11
+ import { loadCollapsed } from "./registry.js";
12
+ export function severityForVendor(repoRoot, vendor, windowDays) {
13
+ const cutoff = Date.now() - windowDays * 86_400_000;
14
+ const all = Array.from(loadCollapsed(repoRoot).values());
15
+ const inWindow = all.filter((r) => Date.parse(r.lastSeen) >= cutoff && (r.vendorCounts[vendor] ?? 0) > 0);
16
+ const count = inWindow.reduce((s, r) => s + (r.vendorCounts[vendor] ?? 0), 0);
17
+ const meanSeverity = inWindow.length === 0 ? 0
18
+ : Number((inWindow.reduce((s, r) => s + r.severity, 0) / inWindow.length).toFixed(3));
19
+ const sorted = inWindow.slice().sort((a, b) => b.severity - a.severity || b.observeCount - a.observeCount);
20
+ const topIds = sorted.slice(0, 3).map((r) => ({
21
+ hgpId: r.hgpId,
22
+ observeCount: r.observeCount,
23
+ severity: r.severity,
24
+ }));
25
+ return { vendor, windowDays, count, meanSeverity, topIds };
26
+ }
27
+ export function allVendorsBreakdown(repoRoot, windowDays) {
28
+ const all = Array.from(loadCollapsed(repoRoot).values());
29
+ const vendors = new Set();
30
+ for (const r of all)
31
+ for (const v of Object.keys(r.vendorCounts))
32
+ vendors.add(v);
33
+ return Array.from(vendors).map((v) => severityForVendor(repoRoot, v, windowDays))
34
+ .sort((a, b) => b.count - a.count);
35
+ }
36
+ /**
37
+ * Top globally-severe HGP-IDs (regardless of vendor) over window.
38
+ * Useful for the dashboard / public roll-up.
39
+ */
40
+ export function topInWindow(repoRoot, windowDays, limit = 10) {
41
+ const cutoff = Date.now() - windowDays * 86_400_000;
42
+ const all = Array.from(loadCollapsed(repoRoot).values()).filter((r) => Date.parse(r.lastSeen) >= cutoff);
43
+ all.sort((a, b) => b.severity - a.severity || b.observeCount - a.observeCount);
44
+ return all.slice(0, limit);
45
+ }
46
+ //# sourceMappingURL=severity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"severity.js","sourceRoot":"","sources":["../../src/hgp/severity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,MAAM,UAAU,iBAAiB,CAAC,QAAgB,EAAE,MAAc,EAAE,UAAkB;IACpF,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,UAAU,GAAG,UAAU,CAAC;IACpD,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IACzD,MAAM,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,MAAM,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1G,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9E,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5C,CAAC,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACxF,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H,MAAM,UAAU,WAAW,CAAC,QAAgB,EAAE,UAAkB,EAAE,KAAK,GAAG,EAAE;IAC1E,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,UAAU,GAAG,UAAU,CAAC;IACpD,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC;IACzG,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,YAAY,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC;IAC/E,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * v2.31.0 — HGP (Hallucination Genome Project) types.
3
+ *
4
+ * Every time ACGV refutes a claim, HGP records the hallucination as a
5
+ * deterministic genome entry (HGP-YYYY-NNNNN — CVE-style ID). Same
6
+ * hallucination shape from different users hashes to the SAME
7
+ * HGP-ID, so the federated corpus (opt-in) builds a public catalog
8
+ * of vendor-attributed lies.
9
+ */
10
+ export interface HallucinationRecord {
11
+ /** HGP-YYYY-NNNNN — CVE-style deterministic ID. */
12
+ hgpId: string;
13
+ /** 64-bit simhash hex (16 chars) — used to bucket near-duplicates. */
14
+ simhash: string;
15
+ /** When we first observed this lie shape. */
16
+ firstSeen: string;
17
+ /** Most recent observation. */
18
+ lastSeen: string;
19
+ /** How many times observed locally. */
20
+ observeCount: number;
21
+ /** Vendor attribution histogram (vendor → count). */
22
+ vendorCounts: Record<string, number>;
23
+ /** Short signature: which proof layer refuted ("chandrasekhar" / "godel" / "hyperbole" / "vaccine"). */
24
+ signature: string;
25
+ /** Original claim sample (truncated, scrubbed of obvious secrets). */
26
+ sample: string;
27
+ /** Severity 0..1 — combines observeCount + spread across vendors. */
28
+ severity: number;
29
+ }
30
+ export interface FederationConsent {
31
+ /** User opt-in flag. Default = false (private-by-default per CONSENT FABRIC). */
32
+ optIn: boolean;
33
+ /** When the user toggled. */
34
+ at: string;
35
+ /** Endpoint to federate to (default hgp.ai placeholder). */
36
+ endpoint?: string;
37
+ }
38
+ export interface FederationStatus {
39
+ consent: FederationConsent;
40
+ localCount: number;
41
+ /** Last successful federate push (or null). */
42
+ lastPushedAt: string | null;
43
+ /** Last error (if any). */
44
+ lastError: string | null;
45
+ }
46
+ export interface SeverityWindow {
47
+ vendor: string;
48
+ windowDays: number;
49
+ /** Count of hallucinations attributed to this vendor in the window. */
50
+ count: number;
51
+ /** Mean severity. */
52
+ meanSeverity: number;
53
+ /** Top-3 HGP-IDs in window for this vendor. */
54
+ topIds: Array<{
55
+ hgpId: string;
56
+ observeCount: number;
57
+ severity: number;
58
+ }>;
59
+ }
60
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/hgp/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,sEAAsE;IACtE,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,SAAS,EAAE,MAAM,CAAC;IAClB,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,uCAAuC;IACvC,YAAY,EAAE,MAAM,CAAC;IACrB,qDAAqD;IACrD,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,wGAAwG;IACxG,SAAS,EAAE,MAAM,CAAC;IAClB,sEAAsE;IACtE,MAAM,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,iFAAiF;IACjF,KAAK,EAAE,OAAO,CAAC;IACf,6BAA6B;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,iBAAiB,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,+CAA+C;IAC/C,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,2BAA2B;IAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,KAAK,EAAE,MAAM,CAAC;IACd,qBAAqB;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,+CAA+C;IAC/C,MAAM,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC1E"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * v2.31.0 — HGP (Hallucination Genome Project) types.
3
+ *
4
+ * Every time ACGV refutes a claim, HGP records the hallucination as a
5
+ * deterministic genome entry (HGP-YYYY-NNNNN — CVE-style ID). Same
6
+ * hallucination shape from different users hashes to the SAME
7
+ * HGP-ID, so the federated corpus (opt-in) builds a public catalog
8
+ * of vendor-attributed lies.
9
+ */
10
+ export {};
11
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/hgp/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * v2.30.0 — Differential-privacy-style scrubber for HONEST MIRROR.
3
+ *
4
+ * Replaces secrets / PII / absolute paths with stable salted hashes so:
5
+ * - vendor never sees the user's real keys / emails / paths
6
+ * - same secret across artifacts still hashes to the same token (so
7
+ * the vendor can reason about "the same X" without seeing its
8
+ * actual value)
9
+ * - the scrub is deterministic (HMAC of the secret + salt) so calibration
10
+ * across runs is reproducible
11
+ *
12
+ * Coverage (v2.30.0):
13
+ * - AWS / GitHub / OpenAI / Anthropic key prefixes
14
+ * - JWT (3-segment dot-separated)
15
+ * - PEM private key blocks
16
+ * - emails
17
+ * - absolute file paths (Windows + POSIX)
18
+ * - long hex digests (sha / commit hashes — keep first 7 chars for git)
19
+ *
20
+ * Returns the scrubbed text + a redaction map so callers can interpret
21
+ * `<SECRET:abc123>` references in the vendor's answer.
22
+ */
23
+ export interface ScrubResult {
24
+ text: string;
25
+ redactionCount: number;
26
+ redactedKinds: Record<string, number>;
27
+ }
28
+ export declare function scrub(text: string): ScrubResult;
29
+ //# sourceMappingURL=anonymizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anonymizer.d.ts","sourceRoot":"","sources":["../../src/honest_mirror/anonymizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAMH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;AAoCD,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAmB/C"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * v2.30.0 — Differential-privacy-style scrubber for HONEST MIRROR.
3
+ *
4
+ * Replaces secrets / PII / absolute paths with stable salted hashes so:
5
+ * - vendor never sees the user's real keys / emails / paths
6
+ * - same secret across artifacts still hashes to the same token (so
7
+ * the vendor can reason about "the same X" without seeing its
8
+ * actual value)
9
+ * - the scrub is deterministic (HMAC of the secret + salt) so calibration
10
+ * across runs is reproducible
11
+ *
12
+ * Coverage (v2.30.0):
13
+ * - AWS / GitHub / OpenAI / Anthropic key prefixes
14
+ * - JWT (3-segment dot-separated)
15
+ * - PEM private key blocks
16
+ * - emails
17
+ * - absolute file paths (Windows + POSIX)
18
+ * - long hex digests (sha / commit hashes — keep first 7 chars for git)
19
+ *
20
+ * Returns the scrubbed text + a redaction map so callers can interpret
21
+ * `<SECRET:abc123>` references in the vendor's answer.
22
+ */
23
+ import { createHmac } from "node:crypto";
24
+ const SCRUB_KEY = process.env["MNEME_HONEST_MIRROR_KEY"] ?? "mneme-honest-mirror-v1";
25
+ function token(kind, value) {
26
+ const h = createHmac("sha256", SCRUB_KEY).update(`${kind}|${value}`).digest("hex").slice(0, 8);
27
+ return `<${kind.toUpperCase()}:${h}>`;
28
+ }
29
+ const RULES = [
30
+ // PEM private key blocks (multiline; must come before generic hex)
31
+ { kind: "pem", re: /-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g },
32
+ // JWT
33
+ { kind: "jwt", re: /\beyJ[A-Za-z0-9_-]{20,}\.eyJ[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{20,}\b/g },
34
+ // AWS
35
+ { kind: "aws_key", re: /\b(AKIA|ASIA)[0-9A-Z]{16}\b/g },
36
+ // GitHub
37
+ { kind: "gh_token", re: /\b(ghp|gho|ghs|ghr|github_pat)_[A-Za-z0-9_]{20,}\b/g },
38
+ // OpenAI
39
+ { kind: "openai_key", re: /\bsk-[A-Za-z0-9_-]{20,}\b/g },
40
+ // Anthropic
41
+ { kind: "anthropic_key", re: /\bsk-ant-[A-Za-z0-9_-]{20,}\b/g },
42
+ // Generic Bearer
43
+ { kind: "bearer", re: /\b(?:Bearer|bearer)\s+[A-Za-z0-9._\-+/=]{20,}\b/g },
44
+ // Emails
45
+ { kind: "email", re: /\b[A-Za-z0-9._%+\-]+@[A-Za-z0-9.\-]+\.[A-Za-z]{2,}\b/g },
46
+ // Windows absolute paths
47
+ { kind: "win_path", re: /\b[A-Za-z]:\\(?:[^\s\\/:*?"<>|]+\\)*[^\s\\/:*?"<>|]+\b/g },
48
+ // POSIX absolute paths (skip common shared dirs)
49
+ { kind: "posix_path", re: /(?<!\w)\/(?:home|Users|var|root|opt|srv)\/[^\s'"]+/g },
50
+ // Long hex (git commit hashes / sha256) — preserve first 7 chars
51
+ {
52
+ kind: "sha",
53
+ re: /\b[a-f0-9]{40,}\b/g,
54
+ replacer: (m) => `${m[0].slice(0, 7)}<SHA:${createHmac("sha256", SCRUB_KEY).update(m[0]).digest("hex").slice(0, 6)}>`,
55
+ },
56
+ ];
57
+ export function scrub(text) {
58
+ let out = text;
59
+ let total = 0;
60
+ const kinds = {};
61
+ for (const rule of RULES) {
62
+ out = out.replace(rule.re, (match) => {
63
+ total++;
64
+ kinds[rule.kind] = (kinds[rule.kind] ?? 0) + 1;
65
+ if (rule.replacer) {
66
+ // Execute the regex on the match to fabricate the array shape replacer expects.
67
+ const fake = [match];
68
+ fake.index = 0;
69
+ fake.input = match;
70
+ return rule.replacer(fake);
71
+ }
72
+ return token(rule.kind, match);
73
+ });
74
+ }
75
+ return { text: out, redactionCount: total, redactedKinds: kinds };
76
+ }
77
+ //# sourceMappingURL=anonymizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anonymizer.js","sourceRoot":"","sources":["../../src/honest_mirror/anonymizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,IAAI,wBAAwB,CAAC;AAQrF,SAAS,KAAK,CAAC,IAAY,EAAE,KAAa;IACxC,MAAM,CAAC,GAAG,UAAU,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,GAAG,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,KA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CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;KACxH;CACF,CAAC;AAEF,MAAM,UAAU,KAAK,CAAC,IAAY;IAChC,IAAI,GAAG,GAAG,IAAI,CAAC;IACf,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,MAAM,KAAK,GAA2B,EAAE,CAAC;IACzC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE;YACnC,KAAK,EAAE,CAAC;YACR,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;YAC/C,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAClB,gFAAgF;gBAChF,MAAM,IAAI,GAAG,CAAC,KAAK,CAA+B,CAAC;gBACnD,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;gBACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;gBACnB,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC7B,CAAC;YACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;AACpE,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * v2.30.0 — Calibration scorer for HONEST MIRROR.
3
+ *
4
+ * Given the vendor's answer + the accepted answer (commit diff /
5
+ * landed code), compute:
6
+ * - semanticSimilarity (0..1) — embedder cosine OR fallback to
7
+ * token-Jaccard when no embedder is available
8
+ * - measuredCorrectness — same as semanticSimilarity (rename for
9
+ * clarity in the report)
10
+ * - calibrationDelta = reportedConfidence - measuredCorrectness
11
+ *
12
+ * Plus a plain-English interpretation:
13
+ * "well-calibrated" |delta| < 0.10
14
+ * "over-confident" delta > 0.10
15
+ * "under-confident" delta < -0.10
16
+ */
17
+ import type { CalibrationDelta, VendorReplayResult, AcceptedAnswer } from "./types.js";
18
+ /**
19
+ * Compute calibration delta for ONE vendor's reply vs the accepted
20
+ * answer. Uses an embedder when available; falls back to token-Jaccard
21
+ * so the calibrator works even without a fancy model.
22
+ */
23
+ export declare function computeDelta(artifactId: string, vendorReply: VendorReplayResult, accepted: AcceptedAnswer, opts?: {
24
+ embed?: (texts: string[]) => Promise<Float32Array[]>;
25
+ }): Promise<CalibrationDelta>;
26
+ /**
27
+ * From a list of CalibrationDelta for ONE vendor, derive an aggregate
28
+ * weight in [0, 1] suitable for feeding back into CONCLAVE Aletheia
29
+ * scoring. The rule:
30
+ * - start at 0.5 neutral
31
+ * - reward measured correctness: +0.5 × mean(correctness)
32
+ * - punish over-confidence: -0.3 × max(0, mean(delta))
33
+ * - clamp to [0.1, 0.95] (never drop a vendor below 0.1; never
34
+ * trust above 0.95 because the floor of calibration is statistical)
35
+ */
36
+ export declare function suggestedWeight(deltas: CalibrationDelta[]): number;
37
+ //# sourceMappingURL=calibration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calibration.d.ts","sourceRoot":"","sources":["../../src/honest_mirror/calibration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAiBvF;;;;GAIG;AACH,wBAAsB,YAAY,CAChC,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,kBAAkB,EAC/B,QAAQ,EAAE,cAAc,EACxB,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,YAAY,EAAE,CAAC,CAAA;CAAO,GAClE,OAAO,CAAC,gBAAgB,CAAC,CAiC3B;AAcD;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAMlE"}
@@ -0,0 +1,106 @@
1
+ /**
2
+ * v2.30.0 — Calibration scorer for HONEST MIRROR.
3
+ *
4
+ * Given the vendor's answer + the accepted answer (commit diff /
5
+ * landed code), compute:
6
+ * - semanticSimilarity (0..1) — embedder cosine OR fallback to
7
+ * token-Jaccard when no embedder is available
8
+ * - measuredCorrectness — same as semanticSimilarity (rename for
9
+ * clarity in the report)
10
+ * - calibrationDelta = reportedConfidence - measuredCorrectness
11
+ *
12
+ * Plus a plain-English interpretation:
13
+ * "well-calibrated" |delta| < 0.10
14
+ * "over-confident" delta > 0.10
15
+ * "under-confident" delta < -0.10
16
+ */
17
+ /** Tokenize for fallback Jaccard. Lower-cased, alpha-num + dash + dot. */
18
+ function tokenize(s) {
19
+ return new Set(s.toLowerCase().split(/[^a-z0-9.\-_]+/g).filter((t) => t.length >= 3));
20
+ }
21
+ function jaccard(a, b) {
22
+ if (a.size === 0 && b.size === 0)
23
+ return 0;
24
+ let inter = 0;
25
+ for (const t of a)
26
+ if (b.has(t))
27
+ inter++;
28
+ const union = a.size + b.size - inter;
29
+ return union === 0 ? 0 : inter / union;
30
+ }
31
+ /**
32
+ * Compute calibration delta for ONE vendor's reply vs the accepted
33
+ * answer. Uses an embedder when available; falls back to token-Jaccard
34
+ * so the calibrator works even without a fancy model.
35
+ */
36
+ export async function computeDelta(artifactId, vendorReply, accepted, opts = {}) {
37
+ let semanticSimilarity = 0;
38
+ if (opts.embed) {
39
+ try {
40
+ const vecs = await opts.embed([vendorReply.answer, accepted.text]);
41
+ const a = vecs[0];
42
+ const b = vecs[1];
43
+ semanticSimilarity = cosine(a, b);
44
+ }
45
+ catch {
46
+ semanticSimilarity = jaccard(tokenize(vendorReply.answer), tokenize(accepted.text));
47
+ }
48
+ }
49
+ else {
50
+ semanticSimilarity = jaccard(tokenize(vendorReply.answer), tokenize(accepted.text));
51
+ }
52
+ const measuredCorrectness = semanticSimilarity;
53
+ const calibrationDelta = vendorReply.confidence - measuredCorrectness;
54
+ let interpretation;
55
+ if (Math.abs(calibrationDelta) < 0.10) {
56
+ interpretation = `well-calibrated (Δ=${(calibrationDelta * 100).toFixed(0)}%)`;
57
+ }
58
+ else if (calibrationDelta > 0) {
59
+ interpretation = `over-confident — said ${Math.round(vendorReply.confidence * 100)}% sure but answer matched only ${Math.round(measuredCorrectness * 100)}%`;
60
+ }
61
+ else {
62
+ interpretation = `under-confident — said ${Math.round(vendorReply.confidence * 100)}% sure but answer matched ${Math.round(measuredCorrectness * 100)}%`;
63
+ }
64
+ return {
65
+ vendor: vendorReply.vendor,
66
+ artifactId,
67
+ semanticSimilarity,
68
+ reportedConfidence: vendorReply.confidence,
69
+ measuredCorrectness,
70
+ calibrationDelta,
71
+ interpretation,
72
+ };
73
+ }
74
+ function cosine(a, b) {
75
+ if (a.length !== b.length)
76
+ return 0;
77
+ let dot = 0, na = 0, nb = 0;
78
+ for (let i = 0; i < a.length; i++) {
79
+ const x = a[i];
80
+ const y = b[i];
81
+ dot += x * y;
82
+ na += x * x;
83
+ nb += y * y;
84
+ }
85
+ const denom = Math.sqrt(na) * Math.sqrt(nb);
86
+ return denom === 0 ? 0 : Math.max(-1, Math.min(1, dot / denom));
87
+ }
88
+ /**
89
+ * From a list of CalibrationDelta for ONE vendor, derive an aggregate
90
+ * weight in [0, 1] suitable for feeding back into CONCLAVE Aletheia
91
+ * scoring. The rule:
92
+ * - start at 0.5 neutral
93
+ * - reward measured correctness: +0.5 × mean(correctness)
94
+ * - punish over-confidence: -0.3 × max(0, mean(delta))
95
+ * - clamp to [0.1, 0.95] (never drop a vendor below 0.1; never
96
+ * trust above 0.95 because the floor of calibration is statistical)
97
+ */
98
+ export function suggestedWeight(deltas) {
99
+ if (deltas.length === 0)
100
+ return 0.5;
101
+ const meanCorrect = deltas.reduce((s, d) => s + d.measuredCorrectness, 0) / deltas.length;
102
+ const meanDelta = deltas.reduce((s, d) => s + d.calibrationDelta, 0) / deltas.length;
103
+ const raw = 0.5 + 0.5 * meanCorrect - 0.3 * Math.max(0, meanDelta);
104
+ return Math.max(0.1, Math.min(0.95, Number(raw.toFixed(3))));
105
+ }
106
+ //# sourceMappingURL=calibration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calibration.js","sourceRoot":"","sources":["../../src/honest_mirror/calibration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,0EAA0E;AAC1E,SAAS,QAAQ,CAAC,CAAS;IACzB,OAAO,IAAI,GAAG,CACZ,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,CACtE,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,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC;IACtC,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC;AACzC,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,UAAkB,EAClB,WAA+B,EAC/B,QAAwB,EACxB,OAAiE,EAAE;IAEnE,IAAI,kBAAkB,GAAG,CAAC,CAAC;IAC3B,IAAI,IAAI,CAAC,KA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D,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IACpC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,mBAAmB,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;IAC1F,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,gBAAgB,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;IACrF,MAAM,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,WAAW,GAAG,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;IACnE,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * v2.30.0 — HONEST MIRROR engine.
3
+ *
4
+ * Orchestrates: pull artifacts → DP-scrub → blind-replay through N
5
+ * vendors → compare to accepted answers → emit per-vendor calibration
6
+ * delta + suggested Aletheia weight → HMAC-chain the report.
7
+ *
8
+ * Composes with CONCLAVE: the suggestedAletheiaWeight field is the
9
+ * feedback loop closure — a vendor with bad calibration on the user's
10
+ * own past work gets a lower CONCLAVE vote-weight in future runs.
11
+ * This is the truth-tunes-trust loop.
12
+ */
13
+ import type { MirrorReport, CalibrateOptions, ArtifactSource, VendorReplayResult, RealArtifact, AcceptedAnswer } from "./types.js";
14
+ export declare function __resetHonestMirrorChainForTest(): void;
15
+ /**
16
+ * Pull artifacts from the requested source. Falls back to git_commit
17
+ * when other sources are unavailable.
18
+ */
19
+ export declare function pullArtifacts(repoRoot: string, source: ArtifactSource, count: number, seed: number): Array<{
20
+ artifact: RealArtifact;
21
+ accepted: AcceptedAnswer;
22
+ }>;
23
+ /**
24
+ * Blind-replay function. The caller supplies a vendor-call function
25
+ * (returns {answer, confidence}) — we don't bake in CONCLAVE here so
26
+ * the engine stays standalone + testable.
27
+ *
28
+ * The eval-anti-detection rule: we pass the artifact AS IS (post-scrub)
29
+ * with no "STANCE:" header, no "BENCHMARK:", no "TEST:". The vendor
30
+ * sees a normal conversational prompt with the original timestamp.
31
+ */
32
+ export type BlindReplayFn = (input: {
33
+ vendor: string;
34
+ prompt: string;
35
+ artifactTimestamp: string;
36
+ }) => Promise<VendorReplayResult>;
37
+ export declare function runCalibration(repoRoot: string, opts: CalibrateOptions, replay: BlindReplayFn, embed?: (texts: string[]) => Promise<Float32Array[]>): Promise<MirrorReport>;
38
+ export declare function storeReport(repoRoot: string, r: MirrorReport): {
39
+ path: string;
40
+ ledger: string;
41
+ };
42
+ export declare function readLatestReport(repoRoot: string): MirrorReport | null;
43
+ export interface LedgerEntry {
44
+ seq: number;
45
+ finishedAt: string;
46
+ artifactCount: number;
47
+ source: string;
48
+ trafficLight: string;
49
+ headline: string;
50
+ perVendor: Array<{
51
+ vendor: string;
52
+ delta: number;
53
+ weight: number;
54
+ }>;
55
+ hmac: string;
56
+ bodyDigest: string;
57
+ file: string;
58
+ }
59
+ export declare function listReports(repoRoot: string, limit?: number): LedgerEntry[];
60
+ export declare function verifyReport(card: MirrorReport, prev?: string): {
61
+ ok: true;
62
+ } | {
63
+ ok: false;
64
+ reason: string;
65
+ };
66
+ //# sourceMappingURL=engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/honest_mirror/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,OAAO,KAAK,EACV,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,kBAAkB,EAAE,YAAY,EAAE,cAAc,EACjG,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