gravito-eval 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +137 -0
- package/dist/cli/index.d.ts +14 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +276 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/src/adjudication/index.d.ts +36 -0
- package/dist/src/adjudication/index.d.ts.map +1 -0
- package/dist/src/adjudication/index.js +149 -0
- package/dist/src/adjudication/index.js.map +1 -0
- package/dist/src/calibration/index.d.ts +38 -0
- package/dist/src/calibration/index.d.ts.map +1 -0
- package/dist/src/calibration/index.js +104 -0
- package/dist/src/calibration/index.js.map +1 -0
- package/dist/src/confidence/index.d.ts +27 -0
- package/dist/src/confidence/index.d.ts.map +1 -0
- package/dist/src/confidence/index.js +168 -0
- package/dist/src/confidence/index.js.map +1 -0
- package/dist/src/index.d.ts +26 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +47 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/matching/index.d.ts +37 -0
- package/dist/src/matching/index.d.ts.map +1 -0
- package/dist/src/matching/index.js +292 -0
- package/dist/src/matching/index.js.map +1 -0
- package/dist/src/metrics/index.d.ts +15 -0
- package/dist/src/metrics/index.d.ts.map +1 -0
- package/dist/src/metrics/index.js +177 -0
- package/dist/src/metrics/index.js.map +1 -0
- package/dist/src/telemetry/index.d.ts +10 -0
- package/dist/src/telemetry/index.d.ts.map +1 -0
- package/dist/src/telemetry/index.js +106 -0
- package/dist/src/telemetry/index.js.map +1 -0
- package/dist/src/types.d.ts +131 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +28 -0
- package/dist/src/types.js.map +1 -0
- package/examples/basic/input.json +76 -0
- package/examples/basic/run.ts +33 -0
- package/package.json +50 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gravito Eval — Calibration Engine
|
|
3
|
+
*
|
|
4
|
+
* The main entry point for evaluating AI system alignment with human judgment.
|
|
5
|
+
* Combines matching, metrics, adjudication, and confidence scoring into
|
|
6
|
+
* a single, easy-to-use evaluation pipeline.
|
|
7
|
+
*/
|
|
8
|
+
import type { Finding, Adjudication, EvalResult } from "../types";
|
|
9
|
+
import { type MultiPassOptions } from "../matching";
|
|
10
|
+
export interface EvalOptions {
|
|
11
|
+
/** Custom matching thresholds */
|
|
12
|
+
matching?: MultiPassOptions;
|
|
13
|
+
/** Human adjudications for AI-only findings (if available) */
|
|
14
|
+
adjudications?: Adjudication[];
|
|
15
|
+
/** Auto-adjudicate AI-only findings when no human adjudications provided */
|
|
16
|
+
autoAdjudicate?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Run a full evaluation of AI findings against human findings.
|
|
20
|
+
*
|
|
21
|
+
* This is the primary entry point for gravito-eval.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { evaluate } from "gravito-eval";
|
|
26
|
+
*
|
|
27
|
+
* const result = evaluate(aiFindings, humanFindings);
|
|
28
|
+
* console.log(`Recall: ${(result.detection.recall * 100).toFixed(1)}%`);
|
|
29
|
+
* console.log(`Precision: ${(result.detection.precision * 100).toFixed(1)}%`);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function evaluate(aiFindings: Finding[], humanFindings: Finding[], options?: EvalOptions): EvalResult;
|
|
33
|
+
export { multiPassMatch, toFlatMatchResult } from "../matching";
|
|
34
|
+
export type { MultiPassOptions } from "../matching";
|
|
35
|
+
export { computeDetectionMetrics, computeRankingMetrics, computeSeverityMetrics, wilsonInterval, } from "../metrics";
|
|
36
|
+
export { computeNovelSignal, computeAdjustedPrecision, autoAdjudicate, batchAutoAdjudicate, } from "../adjudication";
|
|
37
|
+
export { scoreConfidence, scoreFindings } from "../confidence";
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/calibration/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,OAAO,EACP,YAAY,EACZ,UAAU,EAEX,MAAM,UAAU,CAAC;AAClB,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAcpE,MAAM,WAAW,WAAW;IAC1B,iCAAiC;IACjC,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,8DAA8D;IAC9D,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;IAC/B,4EAA4E;IAC5E,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CACtB,UAAU,EAAE,OAAO,EAAE,EACrB,aAAa,EAAE,OAAO,EAAE,EACxB,OAAO,CAAC,EAAE,WAAW,GACpB,UAAU,CA8DZ;AAyBD,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,cAAc,EACd,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Gravito Eval — Calibration Engine
|
|
4
|
+
*
|
|
5
|
+
* The main entry point for evaluating AI system alignment with human judgment.
|
|
6
|
+
* Combines matching, metrics, adjudication, and confidence scoring into
|
|
7
|
+
* a single, easy-to-use evaluation pipeline.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.scoreFindings = exports.scoreConfidence = exports.batchAutoAdjudicate = exports.autoAdjudicate = exports.computeAdjustedPrecision = exports.computeNovelSignal = exports.wilsonInterval = exports.computeSeverityMetrics = exports.computeRankingMetrics = exports.computeDetectionMetrics = exports.toFlatMatchResult = exports.multiPassMatch = void 0;
|
|
11
|
+
exports.evaluate = evaluate;
|
|
12
|
+
const matching_1 = require("../matching");
|
|
13
|
+
const metrics_1 = require("../metrics");
|
|
14
|
+
const adjudication_1 = require("../adjudication");
|
|
15
|
+
/**
|
|
16
|
+
* Run a full evaluation of AI findings against human findings.
|
|
17
|
+
*
|
|
18
|
+
* This is the primary entry point for gravito-eval.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { evaluate } from "gravito-eval";
|
|
23
|
+
*
|
|
24
|
+
* const result = evaluate(aiFindings, humanFindings);
|
|
25
|
+
* console.log(`Recall: ${(result.detection.recall * 100).toFixed(1)}%`);
|
|
26
|
+
* console.log(`Precision: ${(result.detection.precision * 100).toFixed(1)}%`);
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
function evaluate(aiFindings, humanFindings, options) {
|
|
30
|
+
// Step 1: Multi-pass matching
|
|
31
|
+
const matchResult = (0, matching_1.multiPassMatch)(aiFindings, humanFindings, options?.matching);
|
|
32
|
+
// Step 2: Detection metrics
|
|
33
|
+
const detection = (0, metrics_1.computeDetectionMetrics)(matchResult, aiFindings.length, humanFindings.length);
|
|
34
|
+
// Step 3: Ranking metrics
|
|
35
|
+
const ranking = (0, metrics_1.computeRankingMetrics)(aiFindings, humanFindings, matchResult);
|
|
36
|
+
// Step 4: Severity agreement
|
|
37
|
+
const severity = (0, metrics_1.computeSeverityMetrics)(matchResult);
|
|
38
|
+
// Step 5: Novel signal (optional)
|
|
39
|
+
let novelSignal = undefined;
|
|
40
|
+
let adjustedPrecision = undefined;
|
|
41
|
+
if (matchResult.aiOnly.length > 0) {
|
|
42
|
+
const adjudications = options?.adjudications ??
|
|
43
|
+
(options?.autoAdjudicate !== false ? (0, adjudication_1.batchAutoAdjudicate)(matchResult.aiOnly) : []);
|
|
44
|
+
if (adjudications.length > 0) {
|
|
45
|
+
novelSignal = (0, adjudication_1.computeNovelSignal)(matchResult.aiOnly, adjudications);
|
|
46
|
+
adjustedPrecision = (0, adjudication_1.computeAdjustedPrecision)(detection.matchedCount, novelSignal.validCount, detection.totalAI);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// Step 6: Verdict
|
|
50
|
+
const verdict = determineVerdict(detection, matchResult);
|
|
51
|
+
// Flatten all match pairs
|
|
52
|
+
const allMatches = [
|
|
53
|
+
...matchResult.strictMatches,
|
|
54
|
+
...matchResult.crossCategoryMatches,
|
|
55
|
+
...matchResult.conceptualMatches,
|
|
56
|
+
];
|
|
57
|
+
return {
|
|
58
|
+
detection,
|
|
59
|
+
ranking,
|
|
60
|
+
severity,
|
|
61
|
+
novelSignal,
|
|
62
|
+
matchBreakdown: {
|
|
63
|
+
strict: matchResult.summary.strict_matched,
|
|
64
|
+
crossCategory: matchResult.summary.cross_category_matched,
|
|
65
|
+
conceptual: matchResult.summary.conceptual_matched,
|
|
66
|
+
},
|
|
67
|
+
matches: allMatches,
|
|
68
|
+
aiOnly: matchResult.aiOnly,
|
|
69
|
+
humanOnly: matchResult.humanOnly,
|
|
70
|
+
adjustedPrecision,
|
|
71
|
+
verdict,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
// ─── Verdict Logic ────────────────────────────────────────────────────────
|
|
75
|
+
function determineVerdict(detection, matchResult) {
|
|
76
|
+
if (detection.totalAI < 3 || detection.totalHuman < 3) {
|
|
77
|
+
return "INSUFFICIENT_DATA";
|
|
78
|
+
}
|
|
79
|
+
if (detection.recall >= 0.60 && detection.precision >= 0.50) {
|
|
80
|
+
return "PASS";
|
|
81
|
+
}
|
|
82
|
+
if (detection.recall >= 0.40 || detection.precision >= 0.35) {
|
|
83
|
+
return "PARTIAL";
|
|
84
|
+
}
|
|
85
|
+
return "FAIL";
|
|
86
|
+
}
|
|
87
|
+
// ─── Re-exports ───────────────────────────────────────────────────────────
|
|
88
|
+
var matching_2 = require("../matching");
|
|
89
|
+
Object.defineProperty(exports, "multiPassMatch", { enumerable: true, get: function () { return matching_2.multiPassMatch; } });
|
|
90
|
+
Object.defineProperty(exports, "toFlatMatchResult", { enumerable: true, get: function () { return matching_2.toFlatMatchResult; } });
|
|
91
|
+
var metrics_2 = require("../metrics");
|
|
92
|
+
Object.defineProperty(exports, "computeDetectionMetrics", { enumerable: true, get: function () { return metrics_2.computeDetectionMetrics; } });
|
|
93
|
+
Object.defineProperty(exports, "computeRankingMetrics", { enumerable: true, get: function () { return metrics_2.computeRankingMetrics; } });
|
|
94
|
+
Object.defineProperty(exports, "computeSeverityMetrics", { enumerable: true, get: function () { return metrics_2.computeSeverityMetrics; } });
|
|
95
|
+
Object.defineProperty(exports, "wilsonInterval", { enumerable: true, get: function () { return metrics_2.wilsonInterval; } });
|
|
96
|
+
var adjudication_2 = require("../adjudication");
|
|
97
|
+
Object.defineProperty(exports, "computeNovelSignal", { enumerable: true, get: function () { return adjudication_2.computeNovelSignal; } });
|
|
98
|
+
Object.defineProperty(exports, "computeAdjustedPrecision", { enumerable: true, get: function () { return adjudication_2.computeAdjustedPrecision; } });
|
|
99
|
+
Object.defineProperty(exports, "autoAdjudicate", { enumerable: true, get: function () { return adjudication_2.autoAdjudicate; } });
|
|
100
|
+
Object.defineProperty(exports, "batchAutoAdjudicate", { enumerable: true, get: function () { return adjudication_2.batchAutoAdjudicate; } });
|
|
101
|
+
var confidence_1 = require("../confidence");
|
|
102
|
+
Object.defineProperty(exports, "scoreConfidence", { enumerable: true, get: function () { return confidence_1.scoreConfidence; } });
|
|
103
|
+
Object.defineProperty(exports, "scoreFindings", { enumerable: true, get: function () { return confidence_1.scoreFindings; } });
|
|
104
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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1C,sCAKoB;AAJlB,kHAAA,uBAAuB,OAAA;AACvB,gHAAA,qBAAqB,OAAA;AACrB,iHAAA,sBAAsB,OAAA;AACtB,yGAAA,cAAc,OAAA;AAEhB,gDAKyB;AAJvB,kHAAA,kBAAkB,OAAA;AAClB,wHAAA,wBAAwB,OAAA;AACxB,8GAAA,cAAc,OAAA;AACd,mHAAA,mBAAmB,OAAA;AAErB,4CAA+D;AAAtD,6GAAA,eAAe,OAAA;AAAE,2GAAA,aAAa,OAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gravito Eval — Confidence Scoring
|
|
3
|
+
*
|
|
4
|
+
* Scores individual findings on a 0–1 confidence scale based on
|
|
5
|
+
* observable signal factors. Uses generic weights suitable for
|
|
6
|
+
* any AI evaluation domain.
|
|
7
|
+
*
|
|
8
|
+
* Applies nonlinear scaling to spread the distribution across
|
|
9
|
+
* the 0.3–0.95 range (avoiding the common clustering at 0.6–0.7).
|
|
10
|
+
*/
|
|
11
|
+
import type { Finding, ScoredFinding } from "../types";
|
|
12
|
+
/**
|
|
13
|
+
* Score a single finding's confidence level.
|
|
14
|
+
*
|
|
15
|
+
* Returns a value between 0 and 1 where:
|
|
16
|
+
* - 0.0–0.3: Very low confidence (likely noise)
|
|
17
|
+
* - 0.3–0.5: Low confidence (needs review)
|
|
18
|
+
* - 0.5–0.7: Moderate confidence (plausible)
|
|
19
|
+
* - 0.7–0.85: High confidence (likely valid)
|
|
20
|
+
* - 0.85–1.0: Very high confidence (strong evidence)
|
|
21
|
+
*/
|
|
22
|
+
export declare function scoreConfidence(finding: Finding): ScoredFinding;
|
|
23
|
+
/**
|
|
24
|
+
* Score a batch of findings.
|
|
25
|
+
*/
|
|
26
|
+
export declare function scoreFindings(findings: Finding[]): ScoredFinding[];
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/confidence/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAqB,MAAM,UAAU,CAAC;AAsI1E;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,aAAa,CAa/D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,aAAa,EAAE,CAElE"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Gravito Eval — Confidence Scoring
|
|
4
|
+
*
|
|
5
|
+
* Scores individual findings on a 0–1 confidence scale based on
|
|
6
|
+
* observable signal factors. Uses generic weights suitable for
|
|
7
|
+
* any AI evaluation domain.
|
|
8
|
+
*
|
|
9
|
+
* Applies nonlinear scaling to spread the distribution across
|
|
10
|
+
* the 0.3–0.95 range (avoiding the common clustering at 0.6–0.7).
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.scoreConfidence = scoreConfidence;
|
|
14
|
+
exports.scoreFindings = scoreFindings;
|
|
15
|
+
// ─── Signal Analysis ──────────────────────────────────────────────────────
|
|
16
|
+
function countSignals(finding) {
|
|
17
|
+
let count = 0;
|
|
18
|
+
if (finding.description && finding.description.length > 40)
|
|
19
|
+
count++;
|
|
20
|
+
if (finding.category)
|
|
21
|
+
count++;
|
|
22
|
+
if (finding.severity)
|
|
23
|
+
count++;
|
|
24
|
+
if (finding.location)
|
|
25
|
+
count++;
|
|
26
|
+
if (finding.keywords && finding.keywords.length > 0)
|
|
27
|
+
count++;
|
|
28
|
+
return count;
|
|
29
|
+
}
|
|
30
|
+
function isSubjective(finding) {
|
|
31
|
+
const subjectivePatterns = [
|
|
32
|
+
"feel",
|
|
33
|
+
"seem",
|
|
34
|
+
"appear",
|
|
35
|
+
"might",
|
|
36
|
+
"could",
|
|
37
|
+
"possibly",
|
|
38
|
+
"arguably",
|
|
39
|
+
"subjective",
|
|
40
|
+
"opinion",
|
|
41
|
+
"aesthetic",
|
|
42
|
+
];
|
|
43
|
+
const desc = finding.description.toLowerCase();
|
|
44
|
+
return subjectivePatterns.some((p) => desc.includes(p));
|
|
45
|
+
}
|
|
46
|
+
function hasSpecificEvidence(finding) {
|
|
47
|
+
const evidencePatterns = [
|
|
48
|
+
"button",
|
|
49
|
+
"link",
|
|
50
|
+
"form",
|
|
51
|
+
"image",
|
|
52
|
+
"text",
|
|
53
|
+
"header",
|
|
54
|
+
"footer",
|
|
55
|
+
"navigation",
|
|
56
|
+
"color",
|
|
57
|
+
"font",
|
|
58
|
+
"size",
|
|
59
|
+
"spacing",
|
|
60
|
+
"contrast",
|
|
61
|
+
"error",
|
|
62
|
+
"missing",
|
|
63
|
+
"broken",
|
|
64
|
+
"incorrect",
|
|
65
|
+
"404",
|
|
66
|
+
"timeout",
|
|
67
|
+
"slow",
|
|
68
|
+
"pixel",
|
|
69
|
+
"mobile",
|
|
70
|
+
"desktop",
|
|
71
|
+
"screen",
|
|
72
|
+
];
|
|
73
|
+
const desc = finding.description.toLowerCase();
|
|
74
|
+
return evidencePatterns.some((p) => desc.includes(p));
|
|
75
|
+
}
|
|
76
|
+
function hasPatternRepetition(finding) {
|
|
77
|
+
// Check if keywords suggest a recurring pattern
|
|
78
|
+
if (finding.keywords && finding.keywords.length >= 3)
|
|
79
|
+
return true;
|
|
80
|
+
// Check if description mentions multiple instances
|
|
81
|
+
const desc = finding.description.toLowerCase();
|
|
82
|
+
return /\b(multiple|several|many|all|every|each|throughout)\b/.test(desc);
|
|
83
|
+
}
|
|
84
|
+
// ─── Factor Computation ───────────────────────────────────────────────────
|
|
85
|
+
function computeFactors(finding) {
|
|
86
|
+
const signals = countSignals(finding);
|
|
87
|
+
const maxSignals = 5;
|
|
88
|
+
return {
|
|
89
|
+
signal_strength: Math.min(signals / maxSignals, 1),
|
|
90
|
+
cross_signal_support: hasSpecificEvidence(finding) ? 0.8 : 0.3,
|
|
91
|
+
pattern_repetition: hasPatternRepetition(finding) ? 0.7 : 0.2,
|
|
92
|
+
rule_determinism: isSubjective(finding) ? 0.2 : 0.7,
|
|
93
|
+
clarity_of_evidence: Math.min(finding.description.length / 150, 1),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
// ─── Confidence Computation ───────────────────────────────────────────────
|
|
97
|
+
/**
|
|
98
|
+
* Generic weights for confidence scoring.
|
|
99
|
+
* These are intentionally balanced — not tuned for any specific domain.
|
|
100
|
+
*/
|
|
101
|
+
const GENERIC_WEIGHTS = {
|
|
102
|
+
signal_strength: 0.20,
|
|
103
|
+
cross_signal_support: 0.25,
|
|
104
|
+
pattern_repetition: 0.15,
|
|
105
|
+
rule_determinism: 0.20,
|
|
106
|
+
clarity_of_evidence: 0.20,
|
|
107
|
+
};
|
|
108
|
+
function computeRawConfidence(factors) {
|
|
109
|
+
let raw = 0;
|
|
110
|
+
for (const [key, weight] of Object.entries(GENERIC_WEIGHTS)) {
|
|
111
|
+
raw += factors[key] * weight;
|
|
112
|
+
}
|
|
113
|
+
return raw;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Apply nonlinear scaling to spread the distribution.
|
|
117
|
+
* Uses a sigmoid-like transform to push values away from the center.
|
|
118
|
+
*/
|
|
119
|
+
function applyNonlinearScaling(raw) {
|
|
120
|
+
// Shift and scale to spread the 0.4-0.7 cluster
|
|
121
|
+
const centered = (raw - 0.5) * 2.5;
|
|
122
|
+
const sigmoid = 1 / (1 + Math.exp(-centered));
|
|
123
|
+
// Map back to 0.15-0.95 range
|
|
124
|
+
return 0.15 + sigmoid * 0.80;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Apply severity bonus/penalty.
|
|
128
|
+
*/
|
|
129
|
+
function applySeverityAdjustment(confidence, severity) {
|
|
130
|
+
const adjustments = {
|
|
131
|
+
critical: 0.10,
|
|
132
|
+
high: 0.05,
|
|
133
|
+
medium: 0.00,
|
|
134
|
+
low: -0.05,
|
|
135
|
+
};
|
|
136
|
+
return Math.max(0, Math.min(1, confidence + (adjustments[severity] ?? 0)));
|
|
137
|
+
}
|
|
138
|
+
// ─── Public API ───────────────────────────────────────────────────────────
|
|
139
|
+
/**
|
|
140
|
+
* Score a single finding's confidence level.
|
|
141
|
+
*
|
|
142
|
+
* Returns a value between 0 and 1 where:
|
|
143
|
+
* - 0.0–0.3: Very low confidence (likely noise)
|
|
144
|
+
* - 0.3–0.5: Low confidence (needs review)
|
|
145
|
+
* - 0.5–0.7: Moderate confidence (plausible)
|
|
146
|
+
* - 0.7–0.85: High confidence (likely valid)
|
|
147
|
+
* - 0.85–1.0: Very high confidence (strong evidence)
|
|
148
|
+
*/
|
|
149
|
+
function scoreConfidence(finding) {
|
|
150
|
+
const factors = computeFactors(finding);
|
|
151
|
+
const raw = computeRawConfidence(factors);
|
|
152
|
+
const scaled = applyNonlinearScaling(raw);
|
|
153
|
+
const final = applySeverityAdjustment(scaled, finding.severity);
|
|
154
|
+
return {
|
|
155
|
+
...finding,
|
|
156
|
+
confidence: Math.round(final * 1000) / 1000,
|
|
157
|
+
factors,
|
|
158
|
+
isSubjective: isSubjective(finding),
|
|
159
|
+
signalCount: countSignals(finding),
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Score a batch of findings.
|
|
164
|
+
*/
|
|
165
|
+
function scoreFindings(findings) {
|
|
166
|
+
return findings.map(scoreConfidence);
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/confidence/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;AAkJH,0CAaC;AAKD,sCAEC;AAlKD,6EAA6E;AAE7E,SAAS,YAAY,CAAC,OAAgB;IACpC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,OAAO,CAAC,W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EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEhE,OAAO;QACL,GAAG,OAAO;QACV,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,IAAI;QAC3C,OAAO;QACP,YAAY,EAAE,YAAY,CAAC,OAAO,CAAC;QACnC,WAAW,EAAE,YAAY,CAAC,OAAO,CAAC;KACnC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAgB,aAAa,CAAC,QAAmB;IAC/C,OAAO,QAAQ,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gravito Eval
|
|
3
|
+
*
|
|
4
|
+
* Measure how closely AI decisions match human judgment —
|
|
5
|
+
* and where they add new signal.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { evaluate } from "gravito-eval";
|
|
10
|
+
*
|
|
11
|
+
* const result = evaluate(aiFindings, humanFindings);
|
|
12
|
+
* console.log(`Recall: ${(result.detection.recall * 100).toFixed(1)}%`);
|
|
13
|
+
* console.log(`Precision: ${(result.detection.precision * 100).toFixed(1)}%`);
|
|
14
|
+
* console.log(`F1: ${(result.detection.f1 * 100).toFixed(1)}%`);
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export { evaluate } from "./calibration";
|
|
18
|
+
export type { EvalOptions } from "./calibration";
|
|
19
|
+
export { multiPassMatch, toFlatMatchResult, keywordSimilarity } from "./matching";
|
|
20
|
+
export type { MultiPassOptions } from "./matching";
|
|
21
|
+
export { computeDetectionMetrics, computeRankingMetrics, computeSeverityMetrics, wilsonInterval, } from "./metrics";
|
|
22
|
+
export { computeNovelSignal, computeAdjustedPrecision, autoAdjudicate, batchAutoAdjudicate, } from "./adjudication";
|
|
23
|
+
export { scoreConfidence, scoreFindings } from "./confidence";
|
|
24
|
+
export { trackRun } from "./telemetry";
|
|
25
|
+
export type { Finding, MatchPair, MatchResult, MultiPassMatchResult, Adjudication, AdjudicationLabel, DetectionMetrics, RankingMetrics, SeverityMetrics, NovelSignalMetrics, ConfidenceInterval, EvalResult, ScoredFinding, ConfidenceFactors, IssueCategory, SeverityLevel, } from "./types";
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAClF,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGnD,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,cAAc,GACf,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,cAAc,EACd,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG9D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,YAAY,EACV,OAAO,EACP,SAAS,EACT,WAAW,EACX,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,aAAa,GACd,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Gravito Eval
|
|
4
|
+
*
|
|
5
|
+
* Measure how closely AI decisions match human judgment —
|
|
6
|
+
* and where they add new signal.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { evaluate } from "gravito-eval";
|
|
11
|
+
*
|
|
12
|
+
* const result = evaluate(aiFindings, humanFindings);
|
|
13
|
+
* console.log(`Recall: ${(result.detection.recall * 100).toFixed(1)}%`);
|
|
14
|
+
* console.log(`Precision: ${(result.detection.precision * 100).toFixed(1)}%`);
|
|
15
|
+
* console.log(`F1: ${(result.detection.f1 * 100).toFixed(1)}%`);
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.trackRun = exports.scoreFindings = exports.scoreConfidence = exports.batchAutoAdjudicate = exports.autoAdjudicate = exports.computeAdjustedPrecision = exports.computeNovelSignal = exports.wilsonInterval = exports.computeSeverityMetrics = exports.computeRankingMetrics = exports.computeDetectionMetrics = exports.keywordSimilarity = exports.toFlatMatchResult = exports.multiPassMatch = exports.evaluate = void 0;
|
|
20
|
+
// Main entry point
|
|
21
|
+
var calibration_1 = require("./calibration");
|
|
22
|
+
Object.defineProperty(exports, "evaluate", { enumerable: true, get: function () { return calibration_1.evaluate; } });
|
|
23
|
+
// Matching
|
|
24
|
+
var matching_1 = require("./matching");
|
|
25
|
+
Object.defineProperty(exports, "multiPassMatch", { enumerable: true, get: function () { return matching_1.multiPassMatch; } });
|
|
26
|
+
Object.defineProperty(exports, "toFlatMatchResult", { enumerable: true, get: function () { return matching_1.toFlatMatchResult; } });
|
|
27
|
+
Object.defineProperty(exports, "keywordSimilarity", { enumerable: true, get: function () { return matching_1.keywordSimilarity; } });
|
|
28
|
+
// Metrics
|
|
29
|
+
var metrics_1 = require("./metrics");
|
|
30
|
+
Object.defineProperty(exports, "computeDetectionMetrics", { enumerable: true, get: function () { return metrics_1.computeDetectionMetrics; } });
|
|
31
|
+
Object.defineProperty(exports, "computeRankingMetrics", { enumerable: true, get: function () { return metrics_1.computeRankingMetrics; } });
|
|
32
|
+
Object.defineProperty(exports, "computeSeverityMetrics", { enumerable: true, get: function () { return metrics_1.computeSeverityMetrics; } });
|
|
33
|
+
Object.defineProperty(exports, "wilsonInterval", { enumerable: true, get: function () { return metrics_1.wilsonInterval; } });
|
|
34
|
+
// Adjudication
|
|
35
|
+
var adjudication_1 = require("./adjudication");
|
|
36
|
+
Object.defineProperty(exports, "computeNovelSignal", { enumerable: true, get: function () { return adjudication_1.computeNovelSignal; } });
|
|
37
|
+
Object.defineProperty(exports, "computeAdjustedPrecision", { enumerable: true, get: function () { return adjudication_1.computeAdjustedPrecision; } });
|
|
38
|
+
Object.defineProperty(exports, "autoAdjudicate", { enumerable: true, get: function () { return adjudication_1.autoAdjudicate; } });
|
|
39
|
+
Object.defineProperty(exports, "batchAutoAdjudicate", { enumerable: true, get: function () { return adjudication_1.batchAutoAdjudicate; } });
|
|
40
|
+
// Confidence
|
|
41
|
+
var confidence_1 = require("./confidence");
|
|
42
|
+
Object.defineProperty(exports, "scoreConfidence", { enumerable: true, get: function () { return confidence_1.scoreConfidence; } });
|
|
43
|
+
Object.defineProperty(exports, "scoreFindings", { enumerable: true, get: function () { return confidence_1.scoreFindings; } });
|
|
44
|
+
// Telemetry
|
|
45
|
+
var telemetry_1 = require("./telemetry");
|
|
46
|
+
Object.defineProperty(exports, "trackRun", { enumerable: true, get: function () { return telemetry_1.trackRun; } });
|
|
47
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH,mBAAmB;AACnB,6CAAyC;AAAhC,uGAAA,QAAQ,OAAA;AAGjB,WAAW;AACX,uCAAkF;AAAzE,0GAAA,cAAc,OAAA;AAAE,6GAAA,iBAAiB,OAAA;AAAE,6GAAA,iBAAiB,OAAA;AAG7D,UAAU;AACV,qCAKmB;AAJjB,kHAAA,uBAAuB,OAAA;AACvB,gHAAA,qBAAqB,OAAA;AACrB,iHAAA,sBAAsB,OAAA;AACtB,yGAAA,cAAc,OAAA;AAGhB,eAAe;AACf,+CAKwB;AAJtB,kHAAA,kBAAkB,OAAA;AAClB,wHAAA,wBAAwB,OAAA;AACxB,8GAAA,cAAc,OAAA;AACd,mHAAA,mBAAmB,OAAA;AAGrB,aAAa;AACb,2CAA8D;AAArD,6GAAA,eAAe,OAAA;AAAE,2GAAA,aAAa,OAAA;AAEvC,YAAY;AACZ,yCAAuC;AAA9B,qGAAA,QAAQ,OAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gravito Eval — Multi-Pass Semantic Matcher
|
|
3
|
+
*
|
|
4
|
+
* Matches AI findings against human findings using three passes:
|
|
5
|
+
* 1. Strict: same category + high keyword similarity (>0.75)
|
|
6
|
+
* 2. Cross-category: high similarity (>0.80) + category equivalence
|
|
7
|
+
* 3. Conceptual merge: cluster related findings, match cluster ↔ single issue
|
|
8
|
+
*
|
|
9
|
+
* Each pass uses greedy one-to-one matching — no double-counting.
|
|
10
|
+
*/
|
|
11
|
+
import type { Finding, MatchResult, MultiPassMatchResult } from "../types";
|
|
12
|
+
/**
|
|
13
|
+
* Compute keyword similarity between two findings.
|
|
14
|
+
* Uses a hybrid approach:
|
|
15
|
+
* 1. Jaccard on full text (description + keywords)
|
|
16
|
+
* 2. Keyword-specific overlap (weighted higher)
|
|
17
|
+
* 3. Location similarity bonus
|
|
18
|
+
* Final score = max(jaccard, keywordOverlap) with location bonus
|
|
19
|
+
*/
|
|
20
|
+
export declare function keywordSimilarity(a: Finding, b: Finding): number;
|
|
21
|
+
export interface MultiPassOptions {
|
|
22
|
+
strictThreshold?: number;
|
|
23
|
+
crossCategoryThreshold?: number;
|
|
24
|
+
clusterThreshold?: number;
|
|
25
|
+
conceptualMatchThreshold?: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Run multi-pass semantic matching between AI and human findings.
|
|
29
|
+
*
|
|
30
|
+
* Returns detailed results with match breakdown by pass type.
|
|
31
|
+
*/
|
|
32
|
+
export declare function multiPassMatch(aiFindings: Finding[], humanFindings: Finding[], options?: MultiPassOptions): MultiPassMatchResult;
|
|
33
|
+
/**
|
|
34
|
+
* Convert MultiPassMatchResult to a flat MatchResult for simpler consumers.
|
|
35
|
+
*/
|
|
36
|
+
export declare function toFlatMatchResult(result: MultiPassMatchResult): MatchResult;
|
|
37
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/matching/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,OAAO,EAEP,WAAW,EACX,oBAAoB,EAErB,MAAM,UAAU,CAAC;AA+BlB;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,MAAM,CAqDhE;AA4MD,MAAM,WAAW,gBAAgB;IAC/B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,OAAO,EAAE,EACrB,aAAa,EAAE,OAAO,EAAE,EACxB,OAAO,CAAC,EAAE,gBAAgB,GACzB,oBAAoB,CAqDtB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,oBAAoB,GAAG,WAAW,CAU3E"}
|