quill/oracle Public Public: anyone can read this; nobody can change it.
workbenchthis machine
Files oracle-mind
| 1 | import { expect, test } from "bun:test"; |
| 2 | import { calibrate, normalize, verdictFor, verdictOnItself } from "./oracle.ts"; |
| 3 | |
| 4 | test("the same question always gets the same verdict", () => { |
| 5 | const first = verdictFor("Should I ship it on Friday?"); |
| 6 | const again = verdictFor("Should I ship it on Friday?"); |
| 7 | expect(again).toEqual(first); |
| 8 | }); |
| 9 | |
| 10 | test("shouting, spacing and punctuation are the same question", () => { |
| 11 | const plain = verdictFor("will it rain"); |
| 12 | expect(verdictFor("Will it rain?")).toEqual(plain); |
| 13 | expect(verdictFor(" WILL IT RAIN!!! ")).toEqual(plain); |
| 14 | expect(normalize(" Will it RAIN? ")).toBe("will it rain"); |
| 15 | }); |
| 16 | |
| 17 | test("different questions get different verdicts", () => { |
| 18 | // Not a guarantee for every pair — a 16-stance table collides — but these |
| 19 | // two must not read as one question. |
| 20 | expect(verdictFor("should I quit")).not.toEqual(verdictFor("should I stay")); |
| 21 | }); |
| 22 | |
| 23 | test("it never admits to a coin flip", () => { |
| 24 | for (const q of ["a", "b", "c", "should I?", "是否", "x".repeat(280)]) { |
| 25 | const { confidence } = verdictFor(q); |
| 26 | expect(confidence).toBeGreaterThanOrEqual(52); |
| 27 | expect(confidence).toBeLessThanOrEqual(98); |
| 28 | } |
| 29 | }); |
| 30 | |
| 31 | test("scoring counts only what a person judged", () => { |
| 32 | const c = calibrate([ |
| 33 | { confidence: 90, outcome: "right" }, |
| 34 | { confidence: 70, outcome: "wrong" }, |
| 35 | { confidence: 99, outcome: "unjudged" }, |
| 36 | ]); |
| 37 | expect(c.judged).toBe(2); |
| 38 | expect(c.right).toBe(1); |
| 39 | expect(c.accuracy).toBe(50); |
| 40 | expect(c.claimed).toBe(80); |
| 41 | expect(c.gap).toBe(30); |
| 42 | }); |
| 43 | |
| 44 | test("nothing judged is not evidence either way", () => { |
| 45 | const c = calibrate([{ confidence: 98, outcome: "unjudged" }]); |
| 46 | expect(c.judged).toBe(0); |
| 47 | expect(c.accuracy).toBeUndefined(); |
| 48 | expect(verdictOnItself(c)).toContain("Nothing judged yet"); |
| 49 | }); |
| 50 | |
| 51 | test("it calls its own bluster", () => { |
| 52 | const bluster = calibrate( |
| 53 | Array.from({ length: 6 }, (_, i) => ({ |
| 54 | confidence: 95, |
| 55 | outcome: i === 0 ? "right" : "wrong", |
| 56 | })), |
| 57 | ); |
| 58 | expect(verdictOnItself(bluster)).toContain("talks a better game"); |
| 59 | }); |