feat: decision-plane wiring — ER-pair decision.match tie-break (@siax/0pt-decision)
CI (SIAX Cloud) / integration (push) Has been skipped
masterplan-lock / check (push) Successful in 4s
CI (SIAX Cloud) / security (push) Successful in 15s
Security Scan (SIAX Cloud) / security (push) Successful in 15s
masterplan-lock / check (pull_request) Successful in 11s
CI (SIAX Cloud) / security (pull_request) Successful in 14s
Security Scan (SIAX Cloud) / security (pull_request) Successful in 16s
CI (SIAX Cloud) / integration (pull_request) Successful in 25s
CI (SIAX Cloud) / quality (push) Failing after 32s
CI (SIAX Cloud) / quality (pull_request) Failing after 33s
CI (SIAX Cloud) / integration (push) Has been skipped
masterplan-lock / check (push) Successful in 4s
CI (SIAX Cloud) / security (push) Successful in 15s
Security Scan (SIAX Cloud) / security (push) Successful in 15s
masterplan-lock / check (pull_request) Successful in 11s
CI (SIAX Cloud) / security (pull_request) Successful in 14s
Security Scan (SIAX Cloud) / security (pull_request) Successful in 16s
CI (SIAX Cloud) / integration (pull_request) Successful in 25s
CI (SIAX Cloud) / quality (push) Failing after 32s
CI (SIAX Cloud) / quality (pull_request) Failing after 33s
- packages/decision: erMatchDecision (0pt.er.pair_match mot siax-decision :4600) - comparePair async + borderline-band (±0.05 av review_threshold) → decision.match (D1 advisory) — deterministisk status GÄLLER om decision abstainar - OPT_DECISION_ER_ENABLED=1-gate (off tills kalibrering) - tests async-anpassade (await generateCandidates/rejects.toThrowError) - typecheck: 13 fel = pre-existing extraction-route (main-paritet), 0 nya fel - tester: 1108 passed | 184 skipped
This commit is contained in:
@@ -30,7 +30,7 @@ function request(overrides: Record<string, unknown> = {}) {
|
||||
}
|
||||
|
||||
describe("similarity primitives", () => {
|
||||
it("normalize folds diacritics + punctuation (Göteborg ≡ goteborg — same block); similarity is 1 for equal, 0 for null", () => {
|
||||
it("normalize folds diacritics + punctuation (Göteborg ≡ goteborg — same block); similarity is 1 for equal, 0 for null", async () => {
|
||||
expect(normalize("Göteborg!")).toBe("goteborg");
|
||||
expect(normalize("Göteborg")).toBe(normalize("goteborg"));
|
||||
expect(normalize("Ørsted")).toBe("orsted");
|
||||
@@ -41,18 +41,18 @@ describe("similarity primitives", () => {
|
||||
});
|
||||
|
||||
describe("EntityResolutionService — candidate API", () => {
|
||||
it("blocking limits comparisons to same-block pairs and reports the reduction", () => {
|
||||
it("blocking limits comparisons to same-block pairs and reports the reduction", async () => {
|
||||
const er = new EntityResolutionService();
|
||||
const res = er.generateCandidates(request());
|
||||
const res = await er.generateCandidates(request());
|
||||
// 4 records = 6 possible pairs; blocking on city → (a1,a2) + (b1,b2) = 2.
|
||||
expect(res.total_possible_comparisons).toBe(6);
|
||||
expect(res.blocked_comparisons).toBe(2);
|
||||
expect(res.pairs).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("scores near-duplicates high (match) and different companies lower, with per-field explanations", () => {
|
||||
it("scores near-duplicates high (match) and different companies lower, with per-field explanations", async () => {
|
||||
const er = new EntityResolutionService();
|
||||
const res = er.generateCandidates(request());
|
||||
const res = await er.generateCandidates(request());
|
||||
const volvo = res.pairs.find((p) => p.record_a === "a1")!;
|
||||
const eric = res.pairs.find((p) => p.record_a === "b1")!;
|
||||
expect(volvo.score).toBeGreaterThan(eric.score);
|
||||
@@ -63,15 +63,15 @@ describe("EntityResolutionService — candidate API", () => {
|
||||
expect(volvo.explanation[1].similarity).toBe(1);
|
||||
});
|
||||
|
||||
it("hands mid-band pairs to human review, never auto-merging them", () => {
|
||||
it("hands mid-band pairs to human review, never auto-merging them", async () => {
|
||||
const er = new EntityResolutionService();
|
||||
const res = er.generateCandidates(request({ auto_match_threshold: 0.95, review_threshold: 0.3 }));
|
||||
const res = await er.generateCandidates(request({ auto_match_threshold: 0.95, review_threshold: 0.3 }));
|
||||
const eric = res.pairs.find((p) => p.record_a === "b1")!;
|
||||
expect(eric.status).toBe("pending_review");
|
||||
expect(res.review_queue.map((p) => p.candidate_id)).toContain(eric.candidate_id);
|
||||
});
|
||||
|
||||
it("product hard rules override the generic score in BOTH directions (§10 hook)", () => {
|
||||
it("product hard rules override the generic score in BOTH directions (§10 hook)", async () => {
|
||||
const er = new EntityResolutionService();
|
||||
er.registerHardRule({
|
||||
rule_id: "vehiq.vin_equality",
|
||||
@@ -80,7 +80,7 @@ describe("EntityResolutionService — candidate API", () => {
|
||||
return a.fields.vin === b.fields.vin ? "force_match" : "force_non_match";
|
||||
},
|
||||
});
|
||||
const res = er.generateCandidates(request());
|
||||
const res = await er.generateCandidates(request());
|
||||
const volvo = res.pairs.find((p) => p.record_a === "a1")!;
|
||||
const eric = res.pairs.find((p) => p.record_a === "b1")!;
|
||||
expect(volvo.status).toBe("match");
|
||||
@@ -91,19 +91,19 @@ describe("EntityResolutionService — candidate API", () => {
|
||||
expect(eric.decided_by).toBe("vehiq.vin_equality");
|
||||
});
|
||||
|
||||
it("refuses unblocked all-pairs runs and invalid thresholds", () => {
|
||||
it("refuses unblocked all-pairs runs and invalid thresholds", async () => {
|
||||
const er = new EntityResolutionService();
|
||||
expect(() => er.generateCandidates(request({ blocking_fields: [] }))).toThrowError(/blocking_fields/);
|
||||
expect(() =>
|
||||
await expect(er.generateCandidates(request({ blocking_fields: [] }))).rejects.toThrowError(/blocking_fields/);
|
||||
await expect(
|
||||
er.generateCandidates(request({ auto_match_threshold: 0.5, review_threshold: 0.6 }))
|
||||
).toThrowError(/review_threshold/);
|
||||
expect(() => er.generateCandidates(request({ records: [RECORDS[0]] }))).toThrowError(/between 2 and 5000/);
|
||||
expect(() => er.generateCandidates(request({ tenant_id: "" }))).toThrowError(/tenant_id/);
|
||||
).rejects.toThrowError(/review_threshold/);
|
||||
await expect(er.generateCandidates(request({ records: [RECORDS[0]] }))).rejects.toThrowError(/between 2 and 5000/);
|
||||
await expect(er.generateCandidates(request({ tenant_id: "" }))).rejects.toThrowError(/tenant_id/);
|
||||
});
|
||||
|
||||
it("records with empty blocking keys are never blocked together", () => {
|
||||
it("records with empty blocking keys are never blocked together", async () => {
|
||||
const er = new EntityResolutionService();
|
||||
const res = er.generateCandidates(
|
||||
const res = await er.generateCandidates(
|
||||
request({
|
||||
records: [
|
||||
{ record_id: "x1", fields: { name: "A", city: null } },
|
||||
|
||||
Reference in New Issue
Block a user