extractor redesign: chains are the deliverable (owner-approved, goal-first)

This commit is contained in:
amosblomqvist
2026-09-30 02:09:25 +03:00
parent 08e64466ad
commit a3aabb3a57
6 changed files with 431 additions and 164 deletions
+36 -1
View File
@@ -9,7 +9,7 @@
import assert from "node:assert/strict";
import { describe, it } from "node:test";
import type { EdgeType } from "../src/core/contracts.ts";
import { chainCoverage, chainsForSelection, chainsToGraph, formatChainLine } from "../src/core/practice.ts";
import { chainCoverage, chainsForSelection, chainsToEdges, chainsToGraph, formatChainLine } from "../src/core/practice.ts";
// ─── fixtures ────────────────────────────────────────────────────────────────
@@ -159,3 +159,38 @@ describe("formatChainLine (the chain table's one-line shape, 2026-09-29)", () =>
assert.equal(formatChainLine({ premises: ["ghost"], conclusion: "c1" }, props), "ghost → Conclusion");
});
});
// ─── chainsToEdges — the extraction seam's expansion (2026-09-30) ────────────
describe("chainsToEdges (the extractor redesign's translation seam)", () => {
it("each premise becomes ONE follows-edge into the conclusion", () => {
const edges = chainsToEdges([{ premises: ["p1", "p2"], conclusion: "c1" }]);
assert.deepEqual(edges, [
{ from: "p1", to: "c1", type: "follows" },
{ from: "p2", to: "c1", type: "follows" },
]);
});
it("chains sharing a conclusion union their premises; the result stays sorted", () => {
const edges = chainsToEdges([
{ premises: ["p2"], conclusion: "c1" },
{ premises: ["p1"], conclusion: "c1" },
]);
assert.deepEqual(edges, [
{ from: "p1", to: "c1", type: "follows" },
{ from: "p2", to: "c1", type: "follows" },
]);
});
it("identical (premise-set, conclusion) chains dedupe silently — restating is a no-op", () => {
const chain = { premises: ["p1", "p2"], conclusion: "c1" };
assert.deepEqual(chainsToEdges([chain, chain, { premises: ["p2", "p1"], conclusion: "c1" }]), [
{ from: "p1", to: "c1", type: "follows" },
{ from: "p2", to: "c1", type: "follows" },
]);
});
it("empty in, empty out — bare propositions ride the propositions list alone", () => {
assert.deepEqual(chainsToEdges([]), []);
});
});