Chapter 9 · section 6 of 8
Proving it
Listing: ask/corpus.test.ts
import test from "node:test";
import assert from "node:assert/strict";
import { quotedWords } from "./check.js";
import { chunkSection } from "./chunk.js";
import { LAWS } from "./corpus.js";
import { EMBEDDED, fingerprint, verifiedPassages } from "./manifest.js";
// Md. Code, Transp. § 16-112, as the General Assembly's site served it on
// 2026-10-06, and as the four MD-C-16-112 laws in corpus.ts were cut from it.
const SECTION_16_112 = `Article - Transportation
§16–112.
(a) (1) In this section the following words have the meanings indicated.
(2) “Credential holder” has the meaning stated in § 16–1001 of this title.
(3) “Display” means the manual surrender of the licensee’s license into the hands of the demanding officer for inspection.
(4) “Electronic credential” has the meaning stated in § 16–1001 of this title.
(b) Each individual driving a motor vehicle on any highway in this State shall have his license with him.
(c) (1) Each individual driving a motor vehicle on any highway in this State shall display the license to any uniformed police officer who demands it.
(2) A credential holder is deemed to have satisfied the display requirement under paragraph (1) of this subsection only if the uniformed police officer is able to access the verification system authorized under § 16–1003 of this title.
(d) Each individual driving a motor vehicle on any highway in this State shall, if requested by the officer, sign his usual signature in the presence of the officer so that the officer may determine whether he is the licensee.
(e) A person may not give the name of another person or give a false or fictitious name to any uniformed police officer who is attempting to determine the identity of a driver of a motor vehicle.
`;
test("every id is unique", () => {
assert.equal(new Set(LAWS.map((law) => law.id)).size, LAWS.length);
});
test("every citation carries the source's own words, so every figure has something to be grounded on", () => {
for (const law of LAWS) assert.ok(quotedWords(law.citation).length > 0, law.id);
});
test("the code's chunks in the corpus are exactly what the chunker cuts from the committed section", () => {
const cut = chunkSection({
code: "MD",
section: "16-112",
cite: "Md. Code, Transp. § 16-112",
heading: "",
asOf: "2026-10-06",
text: SECTION_16_112,
});
assert.deepEqual(
cut.map((chunk) => chunk.id),
["MD-C-16-112-a", "MD-C-16-112-b", "MD-C-16-112-c", "MD-C-16-112-d", "MD-C-16-112-e"],
);
for (const chunk of cut.slice(1)) {
const committed = LAWS.find((law) => law.id === chunk.id);
assert.ok(committed !== undefined, chunk.id);
assert.equal(committed.law, chunk.law);
assert.equal(committed.citation, chunk.citation);
}
});
test("the index holds the corpus as it is now (else run tsx ask/vectors.ts and record the fingerprint)", () => {
assert.equal(LAWS.length, EMBEDDED.laws);
assert.equal(fingerprint(LAWS), EMBEDDED.sha256);
});
test("a passage the page does not say is dropped, and named", () => {
const page = "<p>After failing two or more times, you must wait at least 15 days before retesting.</p>";
const checked = verifiedPassages(
[
"you must wait at least 15 days before retesting",
"you must wait at least 10 days before retesting",
"5 days before retesting",
],
page,
);
assert.deepEqual(checked.passages, ["you must wait at least 15 days before retesting"]);
assert.deepEqual(
checked.dropped.map((each) => each.passage),
["you must wait at least 10 days before retesting", "5 days before retesting"],
);
});
test("a curly quote is not a difference", () => {
const checked = verifiedPassages(["Hold a learner's permit for at least 9 months"], "Hold a learner’s permit for at least 9 months");
assert.equal(checked.passages.length, 1);
}); The third test is the one that holds the corpus to its source. The section’s text is in the test, as the legislature’s site served it, and the test cuts it and compares the pieces with the four laws you typed in Chapter 2. Change a word of MD-C-16-112-c in corpus.ts and the test names the chunk. The deployed suite does this for every one of the corpus’s 143,000 chunks, against the committed section files, and it is the test that makes “the box quotes the law verbatim” a fact rather than an intention.