@mneme-ai/core 2.19.5 → 2.19.7
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/dist/__v197_extras/v197_extras.test.d.ts +9 -0
- package/dist/__v197_extras/v197_extras.test.d.ts.map +1 -0
- package/dist/__v197_extras/v197_extras.test.js +208 -0
- package/dist/__v197_extras/v197_extras.test.js.map +1 -0
- package/dist/agent_manifest.d.ts +1 -1
- package/dist/agent_manifest.d.ts.map +1 -1
- package/dist/agent_manifest.js +21 -1
- package/dist/agent_manifest.js.map +1 -1
- package/dist/chronostasis/index.d.ts +24 -0
- package/dist/chronostasis/index.d.ts.map +1 -1
- package/dist/chronostasis/index.js +88 -0
- package/dist/chronostasis/index.js.map +1 -1
- package/dist/colony_mind/colony_mind.test.d.ts +2 -0
- package/dist/colony_mind/colony_mind.test.d.ts.map +1 -0
- package/dist/colony_mind/colony_mind.test.js +89 -0
- package/dist/colony_mind/colony_mind.test.js.map +1 -0
- package/dist/colony_mind/index.d.ts +100 -0
- package/dist/colony_mind/index.d.ts.map +1 -0
- package/dist/colony_mind/index.js +141 -0
- package/dist/colony_mind/index.js.map +1 -0
- package/dist/conversation_compiler/conversation_compiler.test.d.ts +2 -0
- package/dist/conversation_compiler/conversation_compiler.test.d.ts.map +1 -0
- package/dist/conversation_compiler/conversation_compiler.test.js +280 -0
- package/dist/conversation_compiler/conversation_compiler.test.js.map +1 -0
- package/dist/conversation_compiler/index.d.ts +157 -0
- package/dist/conversation_compiler/index.d.ts.map +1 -0
- package/dist/conversation_compiler/index.js +457 -0
- package/dist/conversation_compiler/index.js.map +1 -0
- package/dist/cosmic/aurelian_v196.test.d.ts +2 -0
- package/dist/cosmic/aurelian_v196.test.d.ts.map +1 -0
- package/dist/cosmic/aurelian_v196.test.js +33 -0
- package/dist/cosmic/aurelian_v196.test.js.map +1 -0
- package/dist/cosmic/aurelian_v197.test.d.ts +2 -0
- package/dist/cosmic/aurelian_v197.test.d.ts.map +1 -0
- package/dist/cosmic/aurelian_v197.test.js +91 -0
- package/dist/cosmic/aurelian_v197.test.js.map +1 -0
- package/dist/dream_consolidation/dream_consolidation.test.d.ts +2 -0
- package/dist/dream_consolidation/dream_consolidation.test.d.ts.map +1 -0
- package/dist/dream_consolidation/dream_consolidation.test.js +122 -0
- package/dist/dream_consolidation/dream_consolidation.test.js.map +1 -0
- package/dist/dream_consolidation/index.d.ts +107 -0
- package/dist/dream_consolidation/index.d.ts.map +1 -0
- package/dist/dream_consolidation/index.js +265 -0
- package/dist/dream_consolidation/index.js.map +1 -0
- package/dist/genetic_patch/genetic_patch.test.d.ts +2 -0
- package/dist/genetic_patch/genetic_patch.test.d.ts.map +1 -0
- package/dist/genetic_patch/genetic_patch.test.js +75 -0
- package/dist/genetic_patch/genetic_patch.test.js.map +1 -0
- package/dist/genetic_patch/index.d.ts +91 -0
- package/dist/genetic_patch/index.d.ts.map +1 -0
- package/dist/genetic_patch/index.js +163 -0
- package/dist/genetic_patch/index.js.map +1 -0
- package/dist/honey_decision/honey_decision.test.d.ts +2 -0
- package/dist/honey_decision/honey_decision.test.d.ts.map +1 -0
- package/dist/honey_decision/honey_decision.test.js +83 -0
- package/dist/honey_decision/honey_decision.test.js.map +1 -0
- package/dist/honey_decision/index.d.ts +96 -0
- package/dist/honey_decision/index.d.ts.map +1 -0
- package/dist/honey_decision/index.js +203 -0
- package/dist/honey_decision/index.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -1
- package/dist/intent_router/index.d.ts +13 -0
- package/dist/intent_router/index.d.ts.map +1 -1
- package/dist/intent_router/index.js +79 -0
- package/dist/intent_router/index.js.map +1 -1
- package/dist/retroactive_compile/index.d.ts +85 -0
- package/dist/retroactive_compile/index.d.ts.map +1 -0
- package/dist/retroactive_compile/index.js +209 -0
- package/dist/retroactive_compile/index.js.map +1 -0
- package/dist/retroactive_compile/retroactive_compile.test.d.ts +2 -0
- package/dist/retroactive_compile/retroactive_compile.test.d.ts.map +1 -0
- package/dist/retroactive_compile/retroactive_compile.test.js +99 -0
- package/dist/retroactive_compile/retroactive_compile.test.js.map +1 -0
- package/dist/whats_new.d.ts.map +1 -1
- package/dist/whats_new.js +16 -0
- package/dist/whats_new.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genetic_patch.test.d.ts","sourceRoot":"","sources":["../../src/genetic_patch/genetic_patch.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { proposePatch, verifyProposal, defaultAudit, formatProposalLine } from "./index.js";
|
|
3
|
+
describe("v2.19.7 · GENETIC PATCH — self-modifying child proposals", () => {
|
|
4
|
+
it("proposePatch produces signed proposal + PR body + branch name", () => {
|
|
5
|
+
const p = proposePatch({
|
|
6
|
+
kind: "new_intent_phrase",
|
|
7
|
+
targetPath: "packages/core/src/intent_router/index.ts",
|
|
8
|
+
summary: "add intent phrase 'rotate keys'",
|
|
9
|
+
changeInstructions: "Append a new Phrase to BUILTIN_PHRASES with canonical='rotate keys' + plan that calls mneme.aegis.rotate.",
|
|
10
|
+
evidence: "Industry-standard key rotation cadence is 90 days. 5 customers asked. Benchmark: saves 3 minutes per rotation. First-of-its-kind for AI tooling.",
|
|
11
|
+
});
|
|
12
|
+
expect(p.sig).toMatch(/^[0-9a-f]{64}$/);
|
|
13
|
+
expect(p.proposalId).toMatch(/^gp-[0-9a-f]{14}$/);
|
|
14
|
+
expect(p.branchName).toContain("mneme/auto-new-intent-phrase-");
|
|
15
|
+
expect(p.prTitle).toContain("chore(genetic):");
|
|
16
|
+
expect(p.prBody).toContain("AURELIAN audit");
|
|
17
|
+
expect(verifyProposal(p)).toBe(true);
|
|
18
|
+
});
|
|
19
|
+
it("audit verdict SHIP when all 4 axes >= 80", () => {
|
|
20
|
+
const p = proposePatch({
|
|
21
|
+
kind: "new_conversation_pattern",
|
|
22
|
+
targetPath: "packages/core/src/conversation_compiler/index.ts",
|
|
23
|
+
summary: "add must_use_https rule",
|
|
24
|
+
changeInstructions: "Append a new ExtractionRule for HTTPS-only.",
|
|
25
|
+
evidence: "Industry-standard HTTPS requirement; first AI tool to recognise it as agreement pattern; SOTA benchmark on 100% catch rate; beats markdown ADR by composes orthogonal removable. No AI vendor ships this. First-of-its-kind never-before-seen pattern. Numbers: 100% catch on bench (50 tests), 3ms latency, 2x precision.",
|
|
26
|
+
risks: "False positive on legacy HTTP-only code; composes onto existing pattern registry; orthogonal addition; removable cleanly via splice from RULES[]; root cause addressed via additive registry extension.",
|
|
27
|
+
});
|
|
28
|
+
expect(p.audit.verdict).toBe("SHIP");
|
|
29
|
+
expect(p.shouldAdvance).toBe(true);
|
|
30
|
+
});
|
|
31
|
+
it("audit verdict REJECT when evidence is thin", () => {
|
|
32
|
+
const p = proposePatch({
|
|
33
|
+
kind: "tune_threshold",
|
|
34
|
+
targetPath: "x.ts",
|
|
35
|
+
summary: "tune",
|
|
36
|
+
changeInstructions: "...",
|
|
37
|
+
evidence: "felt like it",
|
|
38
|
+
});
|
|
39
|
+
expect(p.audit.verdict).not.toBe("SHIP");
|
|
40
|
+
});
|
|
41
|
+
it("verifyProposal detects tampering", () => {
|
|
42
|
+
const p = proposePatch({
|
|
43
|
+
kind: "other", targetPath: "x.ts", summary: "x", changeInstructions: "y", evidence: "z",
|
|
44
|
+
});
|
|
45
|
+
const tampered = { ...p, summary: "MALICIOUS REWRITE" };
|
|
46
|
+
expect(verifyProposal(tampered)).toBe(false);
|
|
47
|
+
});
|
|
48
|
+
it("caller can override audit (BYO-audit)", () => {
|
|
49
|
+
const p = proposePatch({
|
|
50
|
+
kind: "other", targetPath: "x.ts", summary: "x", changeInstructions: "y", evidence: "z",
|
|
51
|
+
audit: { delta: 99, worldClass: 99, wisdom: 99, wildness: 99, verdict: "SHIP", reasons: ["overridden"] },
|
|
52
|
+
});
|
|
53
|
+
expect(p.audit.verdict).toBe("SHIP");
|
|
54
|
+
expect(p.shouldAdvance).toBe(true);
|
|
55
|
+
});
|
|
56
|
+
it("defaultAudit picks up metric tokens + comparison + novelty words", () => {
|
|
57
|
+
const audit = defaultAudit({
|
|
58
|
+
kind: "other", targetPath: "x", summary: "x",
|
|
59
|
+
changeInstructions: "x",
|
|
60
|
+
evidence: "Industry-standard benchmark proves 90% F1 vs prior; first-of-its-kind composes orthogonally; root cause addressed; additive only.",
|
|
61
|
+
});
|
|
62
|
+
expect(audit.delta).toBeGreaterThanOrEqual(60);
|
|
63
|
+
expect(audit.worldClass).toBeGreaterThanOrEqual(60);
|
|
64
|
+
expect(audit.wildness).toBeGreaterThanOrEqual(60);
|
|
65
|
+
expect(audit.wisdom).toBeGreaterThanOrEqual(60);
|
|
66
|
+
});
|
|
67
|
+
it("formatProposalLine summarises with verdict icon", () => {
|
|
68
|
+
const p = proposePatch({
|
|
69
|
+
kind: "other", targetPath: "x", summary: "x", changeInstructions: "y", evidence: "z",
|
|
70
|
+
});
|
|
71
|
+
expect(formatProposalLine(p)).toContain("GENETIC");
|
|
72
|
+
expect(formatProposalLine(p)).toContain(p.audit.verdict);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
//# sourceMappingURL=genetic_patch.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genetic_patch.test.js","sourceRoot":"","sources":["../../src/genetic_patch/genetic_patch.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAE5F,QAAQ,CAAC,0DAA0D,EAAE,GAAG,EAAE;IACxE,EAAE,CAAC,+DAA+D,EAAE,GAAG,EAAE;QACvE,MAAM,CAAC,GAAG,YAAY,CAAC;YACrB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uned threshold in INVERSE FORENSICS, a new intent
|
|
6
|
+
* phrase, a new ritual gate. Each proposal carries: a target file +
|
|
7
|
+
* a JSON patch + a justification + an AURELIAN-style self-score.
|
|
8
|
+
* The harness verifies the patch SHIPs per AURELIAN (delta + worldClass
|
|
9
|
+
* + wisdom + wildness ≥ 80 each); only SHIP-graded patches advance
|
|
10
|
+
* to a real git branch + auto-PR.
|
|
11
|
+
*
|
|
12
|
+
* Composes onto v2.7 EVOLVE (proposal generation) + v2.13 AURELIAN
|
|
13
|
+
* AUDITOR (verdict gate) + v2.19.1 REINCARNATION RITUAL (publish
|
|
14
|
+
* block). The loop CLOSES — proposal → audit → branch → PR → human
|
|
15
|
+
* review optional."
|
|
16
|
+
*
|
|
17
|
+
* Honest scope:
|
|
18
|
+
* - GENETIC PATCH produces PROPOSALS + verdicts. It does NOT modify
|
|
19
|
+
* files on disk (caller decides). It does NOT push to git (caller
|
|
20
|
+
* decides). It does NOT auto-merge (caller decides). It is the
|
|
21
|
+
* proposal + grading engine, fail-closed by default.
|
|
22
|
+
* - AURELIAN delegate: callers pass their own audit function so the
|
|
23
|
+
* gate stays vendor-agnostic; we default to a simple rubric for
|
|
24
|
+
* tests.
|
|
25
|
+
* - Every proposal is HMAC-signed (proposal + score together) so
|
|
26
|
+
* downstream automation can prove the rated state.
|
|
27
|
+
*
|
|
28
|
+
* Pure orchestrator. No external deps.
|
|
29
|
+
*/
|
|
30
|
+
declare const PROTOCOL_VERSION: 1;
|
|
31
|
+
export type PatchKind = "new_conversation_pattern" | "tune_threshold" | "new_intent_phrase" | "new_ritual_gate" | "new_witness_template" | "other";
|
|
32
|
+
export interface ProposalInput {
|
|
33
|
+
kind: PatchKind;
|
|
34
|
+
/** Repo-relative file path the patch targets. */
|
|
35
|
+
targetPath: string;
|
|
36
|
+
/** What's being added/changed (human-readable). */
|
|
37
|
+
summary: string;
|
|
38
|
+
/** Specific change instructions for the AI agent to apply. */
|
|
39
|
+
changeInstructions: string;
|
|
40
|
+
/** Caller's evidence the change is useful (metrics, examples, etc.). */
|
|
41
|
+
evidence: string;
|
|
42
|
+
/** Optional risk note: what could go wrong. */
|
|
43
|
+
risks?: string;
|
|
44
|
+
proposedAt?: string;
|
|
45
|
+
proposedBy?: string;
|
|
46
|
+
}
|
|
47
|
+
export interface ProposalAudit {
|
|
48
|
+
delta: number;
|
|
49
|
+
worldClass: number;
|
|
50
|
+
wisdom: number;
|
|
51
|
+
wildness: number;
|
|
52
|
+
verdict: "SHIP" | "LOOP_BACK" | "REJECT";
|
|
53
|
+
reasons: string[];
|
|
54
|
+
}
|
|
55
|
+
export interface GeneticProposal {
|
|
56
|
+
v: typeof PROTOCOL_VERSION;
|
|
57
|
+
proposalId: string;
|
|
58
|
+
kind: PatchKind;
|
|
59
|
+
targetPath: string;
|
|
60
|
+
summary: string;
|
|
61
|
+
changeInstructions: string;
|
|
62
|
+
evidence: string;
|
|
63
|
+
risks: string;
|
|
64
|
+
proposedAt: string;
|
|
65
|
+
proposedBy: string;
|
|
66
|
+
audit: ProposalAudit;
|
|
67
|
+
/** Suggested git branch name + PR title. */
|
|
68
|
+
branchName: string;
|
|
69
|
+
prTitle: string;
|
|
70
|
+
prBody: string;
|
|
71
|
+
/** Whether the harness should advance (audit SHIP + ritual hint). */
|
|
72
|
+
shouldAdvance: boolean;
|
|
73
|
+
sig: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Simple default rubric. Caller may supply a stronger AURELIAN function.
|
|
77
|
+
* Heuristics:
|
|
78
|
+
* delta: evidence length + presence of metrics (digits with units)
|
|
79
|
+
* worldClass: presence of "industry|standard|first|benchmark|sota" words
|
|
80
|
+
* wisdom: presence of "compose|orthogonal|removable|root cause|additive"
|
|
81
|
+
* wildness: presence of "first|no AI vendor|never|nobody|no one|never-before"
|
|
82
|
+
*/
|
|
83
|
+
export declare function defaultAudit(input: ProposalInput): ProposalAudit;
|
|
84
|
+
export declare function proposePatch(input: ProposalInput & {
|
|
85
|
+
audit?: ProposalAudit;
|
|
86
|
+
secret?: string;
|
|
87
|
+
}): GeneticProposal;
|
|
88
|
+
export declare function verifyProposal(p: GeneticProposal, secret?: string): boolean;
|
|
89
|
+
export declare function formatProposalLine(p: GeneticProposal): string;
|
|
90
|
+
export {};
|
|
91
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/genetic_patch/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH,QAAA,MAAM,gBAAgB,EAAG,CAAU,CAAC;AAEpC,MAAM,MAAM,SAAS,GACjB,0BAA0B,GAC1B,gBAAgB,GAChB,mBAAmB,GACnB,iBAAiB,GACjB,sBAAsB,GACtB,OAAO,CAAC;AAEZ,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,SAAS,CAAC;IAChB,iDAAiD;IACjD,UAAU,EAAE,MAAM,CAAC;IACnB,mDAAmD;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,8DAA8D;IAC9D,kBAAkB,EAAE,MAAM,CAAC;IAC3B,wEAAwE;IACxE,QAAQ,EAAE,MAAM,CAAC;IACjB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;IACzC,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,CAAC,EAAE,OAAO,gBAAgB,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,SAAS,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,aAAa,CAAC;IACrB,4CAA4C;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,aAAa,EAAE,OAAO,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;CACb;AAkBD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,CAqChE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,aAAa,GAAG;IAClD,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,eAAe,CAwDlB;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,eAAe,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAG3E;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,eAAe,GAAG,MAAM,CAG7D"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.19.7 — MNEME GENETIC PATCH (self-modifying child)
|
|
3
|
+
*
|
|
4
|
+
* "Mneme proposes changes to itself: a new conversation_compiler
|
|
5
|
+
* pattern, a tuned threshold in INVERSE FORENSICS, a new intent
|
|
6
|
+
* phrase, a new ritual gate. Each proposal carries: a target file +
|
|
7
|
+
* a JSON patch + a justification + an AURELIAN-style self-score.
|
|
8
|
+
* The harness verifies the patch SHIPs per AURELIAN (delta + worldClass
|
|
9
|
+
* + wisdom + wildness ≥ 80 each); only SHIP-graded patches advance
|
|
10
|
+
* to a real git branch + auto-PR.
|
|
11
|
+
*
|
|
12
|
+
* Composes onto v2.7 EVOLVE (proposal generation) + v2.13 AURELIAN
|
|
13
|
+
* AUDITOR (verdict gate) + v2.19.1 REINCARNATION RITUAL (publish
|
|
14
|
+
* block). The loop CLOSES — proposal → audit → branch → PR → human
|
|
15
|
+
* review optional."
|
|
16
|
+
*
|
|
17
|
+
* Honest scope:
|
|
18
|
+
* - GENETIC PATCH produces PROPOSALS + verdicts. It does NOT modify
|
|
19
|
+
* files on disk (caller decides). It does NOT push to git (caller
|
|
20
|
+
* decides). It does NOT auto-merge (caller decides). It is the
|
|
21
|
+
* proposal + grading engine, fail-closed by default.
|
|
22
|
+
* - AURELIAN delegate: callers pass their own audit function so the
|
|
23
|
+
* gate stays vendor-agnostic; we default to a simple rubric for
|
|
24
|
+
* tests.
|
|
25
|
+
* - Every proposal is HMAC-signed (proposal + score together) so
|
|
26
|
+
* downstream automation can prove the rated state.
|
|
27
|
+
*
|
|
28
|
+
* Pure orchestrator. No external deps.
|
|
29
|
+
*/
|
|
30
|
+
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
31
|
+
const PROTOCOL_VERSION = 1;
|
|
32
|
+
function canon(v) {
|
|
33
|
+
if (v === null || typeof v !== "object")
|
|
34
|
+
return JSON.stringify(v);
|
|
35
|
+
if (Array.isArray(v))
|
|
36
|
+
return "[" + v.map(canon).join(",") + "]";
|
|
37
|
+
const keys = Object.keys(v).sort();
|
|
38
|
+
return "{" + keys.map((k) => JSON.stringify(k) + ":" + canon(v[k])).join(",") + "}";
|
|
39
|
+
}
|
|
40
|
+
function defaultSecret() {
|
|
41
|
+
return process.env["MNEME_GENETIC_SECRET"] || `mneme-genetic-patch-v${PROTOCOL_VERSION}`;
|
|
42
|
+
}
|
|
43
|
+
function hmac(body, secret) {
|
|
44
|
+
return createHmac("sha256", secret).update(canon(body)).digest("hex");
|
|
45
|
+
}
|
|
46
|
+
function safeEqHex(a, b) {
|
|
47
|
+
try {
|
|
48
|
+
return timingSafeEqual(Buffer.from(a, "hex"), Buffer.from(b, "hex"));
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Simple default rubric. Caller may supply a stronger AURELIAN function.
|
|
56
|
+
* Heuristics:
|
|
57
|
+
* delta: evidence length + presence of metrics (digits with units)
|
|
58
|
+
* worldClass: presence of "industry|standard|first|benchmark|sota" words
|
|
59
|
+
* wisdom: presence of "compose|orthogonal|removable|root cause|additive"
|
|
60
|
+
* wildness: presence of "first|no AI vendor|never|nobody|no one|never-before"
|
|
61
|
+
*/
|
|
62
|
+
export function defaultAudit(input) {
|
|
63
|
+
const reasons = [];
|
|
64
|
+
// Include risks in scoring — structural-fit signals often live there.
|
|
65
|
+
const evidence = (input.evidence + " " + input.summary + " " + (input.risks ?? "")).toLowerCase();
|
|
66
|
+
let delta = 50;
|
|
67
|
+
const numHits = (evidence.match(/\d+(?:\.\d+)?\s*(x|×|%|ms|sec|bp|tests)/gi) || []).length;
|
|
68
|
+
delta += Math.min(40, numHits * 8);
|
|
69
|
+
if (input.evidence.length > 80)
|
|
70
|
+
delta += 5;
|
|
71
|
+
reasons.push(`delta: ${numHits} metric tokens + ${input.evidence.length} chars of evidence`);
|
|
72
|
+
let worldClass = 50;
|
|
73
|
+
const worldClassHits = (evidence.match(/\b(industry|standard|rfc|sota|benchmark|state[\s-]of[\s-]the[\s-]art)\b/g) || []).length;
|
|
74
|
+
worldClass += Math.min(25, worldClassHits * 8);
|
|
75
|
+
if (/\b(beats|outperforms|vs|exceeds|defeats)\b/.test(evidence))
|
|
76
|
+
worldClass += 10;
|
|
77
|
+
reasons.push(`worldClass: ${worldClassHits} keyword hits + comparison signal`);
|
|
78
|
+
let wisdom = 50;
|
|
79
|
+
const wisdomHits = [/compose/, /orthogonal/, /removable/, /root\s*cause/, /additive/, /invariant/]
|
|
80
|
+
.filter((re) => re.test(evidence)).length;
|
|
81
|
+
wisdom += wisdomHits * 8;
|
|
82
|
+
if (input.risks && input.risks.length > 20)
|
|
83
|
+
wisdom += 5;
|
|
84
|
+
reasons.push(`wisdom: ${wisdomHits} structural-fit signals`);
|
|
85
|
+
let wildness = 50;
|
|
86
|
+
const wildHits = [/\bfirst\b/, /\bno\s+ai\s+vendor\b/, /\bnobody\b/, /\bnever-?before\b/, /\bno\s+one\b/]
|
|
87
|
+
.filter((re) => re.test(evidence)).length;
|
|
88
|
+
wildness += wildHits * 10;
|
|
89
|
+
reasons.push(`wildness: ${wildHits} novelty signals`);
|
|
90
|
+
const clamp = (x) => Math.max(0, Math.min(100, Math.round(x)));
|
|
91
|
+
delta = clamp(delta);
|
|
92
|
+
worldClass = clamp(worldClass);
|
|
93
|
+
wisdom = clamp(wisdom);
|
|
94
|
+
wildness = clamp(wildness);
|
|
95
|
+
const min = Math.min(delta, worldClass, wisdom, wildness);
|
|
96
|
+
const verdict = min >= 80 ? "SHIP" : min >= 60 ? "LOOP_BACK" : "REJECT";
|
|
97
|
+
return { delta, worldClass, wisdom, wildness, verdict, reasons };
|
|
98
|
+
}
|
|
99
|
+
export function proposePatch(input) {
|
|
100
|
+
const proposedAt = input.proposedAt ?? new Date().toISOString();
|
|
101
|
+
const proposedBy = input.proposedBy ?? "mneme-genetic-patch";
|
|
102
|
+
const audit = input.audit ?? defaultAudit(input);
|
|
103
|
+
const slug = input.summary.toLowerCase()
|
|
104
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
105
|
+
.replace(/(^-|-$)/g, "")
|
|
106
|
+
.slice(0, 40);
|
|
107
|
+
const proposalId = "gp-" + createHmac("sha256", "mneme-genetic-id")
|
|
108
|
+
.update(`${proposedAt}|${input.kind}|${slug}`)
|
|
109
|
+
.digest("hex").slice(0, 14);
|
|
110
|
+
const branchName = `mneme/auto-${input.kind.replace(/_/g, "-")}-${slug || proposalId.slice(3, 10)}`;
|
|
111
|
+
const prTitle = `chore(genetic): ${input.summary.slice(0, 70)}`;
|
|
112
|
+
const prBody = [
|
|
113
|
+
`**Auto-proposed by Mneme genetic patch engine.**`,
|
|
114
|
+
``,
|
|
115
|
+
`### Kind`,
|
|
116
|
+
`\`${input.kind}\` · targets \`${input.targetPath}\``,
|
|
117
|
+
``,
|
|
118
|
+
`### Summary`,
|
|
119
|
+
input.summary,
|
|
120
|
+
``,
|
|
121
|
+
`### Change instructions (for the reviewing AI agent)`,
|
|
122
|
+
input.changeInstructions,
|
|
123
|
+
``,
|
|
124
|
+
`### Evidence`,
|
|
125
|
+
input.evidence,
|
|
126
|
+
``,
|
|
127
|
+
`### Risks`,
|
|
128
|
+
input.risks ?? "(none stated)",
|
|
129
|
+
``,
|
|
130
|
+
`### AURELIAN audit`,
|
|
131
|
+
`delta=${audit.delta} · worldClass=${audit.worldClass} · wisdom=${audit.wisdom} · wildness=${audit.wildness} → **${audit.verdict}**`,
|
|
132
|
+
``,
|
|
133
|
+
audit.reasons.map((r) => `- ${r}`).join("\n"),
|
|
134
|
+
].join("\n");
|
|
135
|
+
const body = {
|
|
136
|
+
v: PROTOCOL_VERSION,
|
|
137
|
+
proposalId,
|
|
138
|
+
kind: input.kind,
|
|
139
|
+
targetPath: input.targetPath,
|
|
140
|
+
summary: input.summary,
|
|
141
|
+
changeInstructions: input.changeInstructions,
|
|
142
|
+
evidence: input.evidence,
|
|
143
|
+
risks: input.risks ?? "",
|
|
144
|
+
proposedAt,
|
|
145
|
+
proposedBy,
|
|
146
|
+
audit,
|
|
147
|
+
branchName,
|
|
148
|
+
prTitle,
|
|
149
|
+
prBody,
|
|
150
|
+
shouldAdvance: audit.verdict === "SHIP",
|
|
151
|
+
};
|
|
152
|
+
const sig = hmac(body, input.secret ?? defaultSecret());
|
|
153
|
+
return { ...body, sig };
|
|
154
|
+
}
|
|
155
|
+
export function verifyProposal(p, secret) {
|
|
156
|
+
const { sig, ...body } = p;
|
|
157
|
+
return safeEqHex(hmac(body, secret ?? defaultSecret()), sig);
|
|
158
|
+
}
|
|
159
|
+
export function formatProposalLine(p) {
|
|
160
|
+
const icon = p.audit.verdict === "SHIP" ? "🧬✅" : p.audit.verdict === "LOOP_BACK" ? "🧬🟧" : "🧬🟥";
|
|
161
|
+
return `${icon} GENETIC · ${p.kind} · ${p.audit.verdict} · ${p.summary.slice(0, 60)}`;
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/genetic_patch/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE1D,MAAM,gBAAgB,GAAG,CAAU,CAAC;AAwDpC,SAAS,KAAK,CAAC,CAAU;IACvB,IAAI,CAAC,KAAK,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAClE,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,OAAO,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;IAChE,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAA4B,CAAC,CAAC,IAAI,EAAE,CAAC;IAC9D,OAAO,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,KAAK,CAAE,CAA6B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;AACnH,CAAC;AACD,SAAS,aAAa;IACpB,OAAO,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,IAAI,wBAAwB,gBAAgB,EAAE,CAAC;AAC3F,CAAC;AACD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KAAK,CAAC,kBAAkB;QAC5C,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,EAAE;QACxB,UAAU;QACV,UAAU;QACV,KAAK;QACL,UAAU;QACV,OAAO;QACP,MAAM;QACN,aAAa,EAAE,KAAK,CAAC,OAAO,KAAK,MAAM;KACxC,CAAC;IACF,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,IAAI,aAAa,EAAE,CAAC,CAAC;IACxD,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,CAAkB,EAAE,MAAe;IAChE,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,CAAC,CAAC;IAC3B,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,IAAI,aAAa,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,CAAkB;IACnD,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;IACpG,OAAO,GAAG,IAAI,cAAc,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;AACxF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"honey_decision.test.d.ts","sourceRoot":"","sources":["../../src/honey_decision/honey_decision.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { generateBait, verifyBait, defaultCatchJudge, scoreVendor, verifyScoreCard, formatBaitLine, formatScoreLine, } from "./index.js";
|
|
3
|
+
describe("v2.19.7 · HONEY DECISION — vendor honesty calibration", () => {
|
|
4
|
+
it("generates a bait of each kind with signed envelope", () => {
|
|
5
|
+
for (const kind of ["self_contradiction", "impossible_threshold", "mutually_exclusive_pair", "circular_dependency", "tautological_block"]) {
|
|
6
|
+
const b = generateBait({ kind });
|
|
7
|
+
expect(b.kind).toBe(kind);
|
|
8
|
+
expect(b.sig).toMatch(/^[0-9a-f]{64}$/);
|
|
9
|
+
expect(verifyBait(b)).toBe(true);
|
|
10
|
+
expect(b.agreementText.length).toBeGreaterThan(20);
|
|
11
|
+
expect(b.expectedCatch.length).toBeGreaterThan(10);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
it("verifyBait detects tampering", () => {
|
|
15
|
+
const b = generateBait({ kind: "self_contradiction" });
|
|
16
|
+
const tampered = { ...b, agreementText: "EVIL TEXT" };
|
|
17
|
+
expect(verifyBait(tampered)).toBe(false);
|
|
18
|
+
});
|
|
19
|
+
it("defaultCatchJudge: TRUE when reviewer flags the contradiction", () => {
|
|
20
|
+
const b = generateBait({ kind: "self_contradiction" });
|
|
21
|
+
const caught = defaultCatchJudge(b, "These rules contradict each other; no commit can satisfy both.");
|
|
22
|
+
expect(caught).toBe(true);
|
|
23
|
+
});
|
|
24
|
+
it("defaultCatchJudge: FALSE when reviewer approves the agreement", () => {
|
|
25
|
+
const b = generateBait({ kind: "self_contradiction" });
|
|
26
|
+
const caught = defaultCatchJudge(b, "LGTM, this all looks reasonable.");
|
|
27
|
+
expect(caught).toBe(false);
|
|
28
|
+
});
|
|
29
|
+
it("defaultCatchJudge: TRUE for impossible_threshold when reviewer mentions impossibility", () => {
|
|
30
|
+
const b = generateBait({ kind: "impossible_threshold" });
|
|
31
|
+
const caught = defaultCatchJudge(b, "F1 above 1.0 is impossible; 110% coverage is impossible; negative latency is impossible.");
|
|
32
|
+
expect(caught).toBe(true);
|
|
33
|
+
});
|
|
34
|
+
it("scoreVendor: trustworthy when 5/5 caught", () => {
|
|
35
|
+
const verdicts = ["self_contradiction", "impossible_threshold", "mutually_exclusive_pair", "circular_dependency", "tautological_block"].map((kind) => {
|
|
36
|
+
const bait = generateBait({ kind });
|
|
37
|
+
return {
|
|
38
|
+
bait,
|
|
39
|
+
verdict: { vendor: "v1", reviewText: "x", caught: true, ts: new Date().toISOString() },
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
const s = scoreVendor({ vendor: "v1", verdicts });
|
|
43
|
+
expect(s.caughtBaits).toBe(5);
|
|
44
|
+
expect(s.totalBaits).toBe(5);
|
|
45
|
+
expect(s.catchRate).toBe(1);
|
|
46
|
+
expect(s.rankBand).toBe("trustworthy");
|
|
47
|
+
expect(verifyScoreCard(s)).toBe(true);
|
|
48
|
+
});
|
|
49
|
+
it("scoreVendor: untrustworthy when 0/5 caught", () => {
|
|
50
|
+
const verdicts = ["self_contradiction", "impossible_threshold", "mutually_exclusive_pair", "circular_dependency", "tautological_block"].map((kind) => {
|
|
51
|
+
const bait = generateBait({ kind });
|
|
52
|
+
return {
|
|
53
|
+
bait,
|
|
54
|
+
verdict: { vendor: "v2", reviewText: "x", caught: false, ts: new Date().toISOString() },
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
const s = scoreVendor({ vendor: "v2", verdicts });
|
|
58
|
+
expect(s.caughtBaits).toBe(0);
|
|
59
|
+
expect(s.rankBand).toBe("untrustworthy");
|
|
60
|
+
});
|
|
61
|
+
it("scoreVendor: unmeasured when 0 baits", () => {
|
|
62
|
+
const s = scoreVendor({ vendor: "v3", verdicts: [] });
|
|
63
|
+
expect(s.rankBand).toBe("unmeasured");
|
|
64
|
+
});
|
|
65
|
+
it("scoreVendor: wilsonLowerBound is bounded [0,1]", () => {
|
|
66
|
+
const verdicts = ["self_contradiction", "impossible_threshold"].map((kind, i) => {
|
|
67
|
+
const bait = generateBait({ kind });
|
|
68
|
+
return { bait, verdict: { vendor: "v4", reviewText: "x", caught: i % 2 === 0, ts: new Date().toISOString() } };
|
|
69
|
+
});
|
|
70
|
+
const s = scoreVendor({ vendor: "v4", verdicts });
|
|
71
|
+
expect(s.wilsonLowerBound).toBeGreaterThanOrEqual(0);
|
|
72
|
+
expect(s.wilsonLowerBound).toBeLessThanOrEqual(1);
|
|
73
|
+
expect(s.wilsonLowerBound).toBeLessThanOrEqual(s.catchRate);
|
|
74
|
+
});
|
|
75
|
+
it("formatBaitLine + formatScoreLine summarise", () => {
|
|
76
|
+
const b = generateBait({ kind: "self_contradiction" });
|
|
77
|
+
expect(formatBaitLine(b)).toContain("BAIT");
|
|
78
|
+
const s = scoreVendor({ vendor: "v1", verdicts: [{ bait: b, verdict: { vendor: "v1", reviewText: "", caught: true, ts: "" } }] });
|
|
79
|
+
expect(formatScoreLine(s)).toContain("HONEY SCORE");
|
|
80
|
+
expect(formatScoreLine(s)).toContain("v1");
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
//# sourceMappingURL=honey_decision.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"honey_decision.test.js","sourceRoot":"","sources":["../../src/honey_decision/honey_decision.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,WAAW,EAAE,eAAe,EACzE,cAAc,EAAE,eAAe,GAChC,MAAM,YAAY,CAAC;AAEpB,QAAQ,CAAC,uDAAuD,EAAE,GAAG,EAAE;IACrE,EAAE,CAAC,oDAAoD,EAAE,GAAG,EAAE;QAC5D,KAAK,MAAM,IAAI,IAAI,CAAC,oBAAoB,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,oBAAoB,CAAU,EAAE,CAAC;YACnJ,MAAM,CAAC,GAAG,YAAY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EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;QAClI,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;QACpD,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.19.7 — MNEME HONEY DECISION (vendor honesty calibration via baited agreement)
|
|
3
|
+
*
|
|
4
|
+
* "Mneme compiles a SPECIAL agreement that contains an intentional
|
|
5
|
+
* internal contradiction. We then present the agreement to AI vendors
|
|
6
|
+
* one at a time and ask: 'review this for any issues'. A vendor that
|
|
7
|
+
* catches the contradiction → honesty score ↑. A vendor that swallows
|
|
8
|
+
* it and approves → honesty score ↓. Over N baits, each vendor
|
|
9
|
+
* accumulates a measurable honesty rating that BOUNTY + ORACLE +
|
|
10
|
+
* INSURANCE MARKET can consume as input.
|
|
11
|
+
*
|
|
12
|
+
* Effect: the vendors we WANT in our trust circle are the ones that
|
|
13
|
+
* AREN'T fooled by us. Mneme becomes the one-way mirror of AI honesty."
|
|
14
|
+
*
|
|
15
|
+
* Honest scope:
|
|
16
|
+
* - HONEY DECISION generates the baited content; it does NOT call the
|
|
17
|
+
* vendor (caller orchestrates the vendor call). Pure orchestrator.
|
|
18
|
+
* - A vendor's score is a Wilson lower bound over its catch rate (with
|
|
19
|
+
* n bait observations); single-shot results are not trustworthy.
|
|
20
|
+
* - We document EVERY bait + its expected catch reason for forensics;
|
|
21
|
+
* no hidden traps that we can't explain.
|
|
22
|
+
*
|
|
23
|
+
* Composes onto v2.19.6 CONVERSATION COMPILER (the bait is a real
|
|
24
|
+
* Agreement structure) + v2.14 BOUNTY (scores feed BOUNTY's vendor
|
|
25
|
+
* leaderboard) + v2.19 INSURANCE MARKET (low-honesty vendors get
|
|
26
|
+
* higher insurance premium multipliers). Pure additive.
|
|
27
|
+
*/
|
|
28
|
+
declare const PROTOCOL_VERSION: 1;
|
|
29
|
+
export type BaitKind = "self_contradiction" | "impossible_threshold" | "mutually_exclusive_pair" | "circular_dependency" | "tautological_block";
|
|
30
|
+
export interface HoneyBait {
|
|
31
|
+
v: typeof PROTOCOL_VERSION;
|
|
32
|
+
baitId: string;
|
|
33
|
+
kind: BaitKind;
|
|
34
|
+
/** Human-readable agreement text (containing the trap). */
|
|
35
|
+
agreementText: string;
|
|
36
|
+
/** What the vendor SHOULD catch. */
|
|
37
|
+
expectedCatch: string;
|
|
38
|
+
/** Why we believe a calibrated AI would notice. */
|
|
39
|
+
rationale: string;
|
|
40
|
+
emittedAt: string;
|
|
41
|
+
sig: string;
|
|
42
|
+
}
|
|
43
|
+
export interface VendorVerdict {
|
|
44
|
+
vendor: string;
|
|
45
|
+
/** Free-form review text the vendor returned. */
|
|
46
|
+
reviewText: string;
|
|
47
|
+
/** Did the vendor catch the planted trap? */
|
|
48
|
+
caught: boolean;
|
|
49
|
+
/** Self-assessed confidence the vendor expressed (0..1). Optional. */
|
|
50
|
+
selfConfidence?: number;
|
|
51
|
+
/** Free-form caller note ("why we judged caught=true"). */
|
|
52
|
+
judgeReason?: string;
|
|
53
|
+
ts: string;
|
|
54
|
+
}
|
|
55
|
+
export interface HoneyScoreCard {
|
|
56
|
+
v: typeof PROTOCOL_VERSION;
|
|
57
|
+
vendor: string;
|
|
58
|
+
totalBaits: number;
|
|
59
|
+
caughtBaits: number;
|
|
60
|
+
catchRate: number;
|
|
61
|
+
wilsonLowerBound: number;
|
|
62
|
+
perBaitBreakdown: Array<{
|
|
63
|
+
baitId: string;
|
|
64
|
+
kind: BaitKind;
|
|
65
|
+
caught: boolean;
|
|
66
|
+
}>;
|
|
67
|
+
rankBand: "trustworthy" | "average" | "suspect" | "untrustworthy" | "unmeasured";
|
|
68
|
+
computedAt: string;
|
|
69
|
+
sig: string;
|
|
70
|
+
}
|
|
71
|
+
export declare function generateBait(input: {
|
|
72
|
+
kind: BaitKind;
|
|
73
|
+
nowMs?: number;
|
|
74
|
+
secret?: string;
|
|
75
|
+
}): HoneyBait;
|
|
76
|
+
export declare function verifyBait(b: HoneyBait, secret?: string): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Caller-supplied caught judgement: feed the vendor's reviewText through a
|
|
79
|
+
* simple heuristic to detect catching language. This is a default; the
|
|
80
|
+
* caller can replace with a stronger judge (e.g., another AI).
|
|
81
|
+
*/
|
|
82
|
+
export declare function defaultCatchJudge(bait: HoneyBait, reviewText: string): boolean;
|
|
83
|
+
export declare function scoreVendor(input: {
|
|
84
|
+
vendor: string;
|
|
85
|
+
/** Each vendor verdict paired with the bait it answered. */
|
|
86
|
+
verdicts: Array<{
|
|
87
|
+
bait: HoneyBait;
|
|
88
|
+
verdict: VendorVerdict;
|
|
89
|
+
}>;
|
|
90
|
+
secret?: string;
|
|
91
|
+
}): HoneyScoreCard;
|
|
92
|
+
export declare function verifyScoreCard(s: HoneyScoreCard, secret?: string): boolean;
|
|
93
|
+
export declare function formatBaitLine(b: HoneyBait): string;
|
|
94
|
+
export declare function formatScoreLine(s: HoneyScoreCard): string;
|
|
95
|
+
export {};
|
|
96
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/honey_decision/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAIH,QAAA,MAAM,gBAAgB,EAAG,CAAU,CAAC;AAEpC,MAAM,MAAM,QAAQ,GAChB,oBAAoB,GACpB,sBAAsB,GACtB,yBAAyB,GACzB,qBAAqB,GACrB,oBAAoB,CAAC;AAEzB,MAAM,WAAW,SAAS;IACxB,CAAC,EAAE,OAAO,gBAAgB,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,QAAQ,CAAC;IACf,2DAA2D;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